本文整理汇总了Golang中github.com/Sirupsen/logrus.Logger.Debugf方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Debugf方法的具体用法?Golang Logger.Debugf怎么用?Golang Logger.Debugf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Sirupsen/logrus.Logger
的用法示例。
在下文中一共展示了Logger.Debugf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createTransferTasks
func createTransferTasks(
logger *logrus.Logger,
cfg config.Config,
dsptchr *dispatcher.Dispatcher,
) {
logger.Debugf(
"Found %d remote hosts for the initial transfers", len(cfg.RemoteHosts),
)
logger.Debugf("Size of initial transfers = %d bytes", cfg.InitTransferSize)
for _, remoteHost := range cfg.RemoteHosts {
host, portStr, err := net.SplitHostPort(remoteHost)
if err != nil {
logger.Fatalf("Parsing remote host `%s`: %s", remoteHost, err.Error())
}
port, err := strconv.ParseInt(portStr, 10, 16)
if err != nil {
logger.Fatalf(
"Parsing remote host's port `%s`: %s",
remoteHost, err.Error(),
)
}
dsptchr.Create(api.TransferSpec{
IP: net.ParseIP(host),
Port: uint16(port),
Size: cfg.InitTransferSize,
})
}
}
示例2: AddLicense
func AddLicense(lic string, stream *logrus.Logger) error {
token := RawToken(lic)
if token == nil {
return fmt.Errorf("License %s is not a valid JWT", lic)
} else {
stream.Debugf("License passed syntax checking: %v", token)
}
lfile := LicenseFile()
if lfile == "" {
return fmt.Errorf("Unable to identify settings file")
}
stream.Infof("License file location: %s", lfile)
// If file doesn't exist, "touch" it
if _, err := os.Stat(lfile); os.IsNotExist(err) {
pdir := path.Dir(lfile)
if pdir == "" {
return fmt.Errorf("Could't determine parent directory of %s: %v", lfile, err)
}
stream.Infof(" Creating parent directories")
err := os.MkdirAll(pdir, 0777)
if err != nil {
return fmt.Errorf("Could't create parent directory %s: %v", pdir, err)
}
stream.Infof(" Creating license file")
f, err := os.Create(lfile)
if err != nil {
return fmt.Errorf("Error trying create new licenses file at %s: %v", lfile, err)
}
f.Close()
}
lics, err := ParseLicenses(lfile, stream)
if err != nil {
return fmt.Errorf("License file at %s is corrupted: %v")
}
// Check for duplicates
for _, l := range lics {
if lic == l {
stream.Infof(" Not adding '%s' because it is a duplicate of an existing entry", l)
return nil
}
}
f, err := os.OpenFile(lfile, os.O_RDWR, 0777)
if err != nil {
return fmt.Errorf("Error trying to open license file %s: %v", lfile, err)
}
_, err = f.Seek(0, 2)
if err != nil {
return fmt.Errorf("Error seeking end of license file %s: %v", lfile, err)
}
_, err = f.Write([]byte(fmt.Sprintf("%s\n", lic)))
if err != nil {
return fmt.Errorf("Error writing license to %s: %v", lfile, err)
}
return nil
}