本文整理匯總了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
}