本文整理汇总了Golang中github.com/Sirupsen/logrus.Logger.Fatalf方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Fatalf方法的具体用法?Golang Logger.Fatalf怎么用?Golang Logger.Fatalf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Sirupsen/logrus.Logger
的用法示例。
在下文中一共展示了Logger.Fatalf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: NewMesosLib
func NewMesosLib(master string, log *logrus.Logger, frameworkInfo *mesosproto.FrameworkInfo, ip string, port int) *MesosLib {
m := &MesosLib{
Log: log,
master: master,
frameworkInfo: frameworkInfo,
ip: ip,
port: port,
Router: mux.NewRouter(),
events: events{
mesosproto.Event_REGISTERED: make(chan *mesosproto.Event, 64),
mesosproto.Event_OFFERS: make(chan *mesosproto.Event, 64),
mesosproto.Event_UPDATE: make(chan *mesosproto.Event, 64),
},
}
if m.ip == "" {
name, err := os.Hostname()
if err != nil {
log.Fatalf("Failed to get hostname: %+v", err)
}
addrs, err := net.LookupHost(name)
if err != nil {
log.Fatalf("Failed to get address for hostname %q: %+v", name, err)
}
for _, addr := range addrs {
if m.ip == "" || !strings.HasPrefix(addr, "127") {
m.ip = addr
}
}
}
m.initAPI()
return m
}
示例3: main
func main() {
var logrusLogger *logrus.Logger = logrus.New()
logrusLogger.Formatter = new(logrus.JSONFormatter)
if len(os.Args) != 2 {
logrus.Error("Must pass an arg to test program...")
os.Exit(0)
}
switch os.Args[1] {
case "logrus.Fatal":
logrusLogger.Fatal("fatal error")
case "logrus.Fatalf":
logrusLogger.Fatalf("fatal error%s", "fatal error")
case "bark.Fatal":
bark.NewLoggerFromLogrus(logrusLogger).Fatal("fatal error")
case "bark.Fatalf":
bark.NewLoggerFromLogrus(logrusLogger).Fatalf("fatal error%s", "fatal error")
}
logrus.Error("Expected fatal methods to exit...")
os.Exit(0)
}