This commit is contained in:
crusader 2017-11-09 15:09:40 +09:00
parent e489d57791
commit d3cb3ba728

View File

@ -6,9 +6,16 @@ import (
"go.uber.org/zap"
)
var Logger *zap.Logger
var logger *zap.Logger
func init() {
func Logger() *zap.Logger {
if nil != logger {
initializeLogger()
}
return logger
}
func initializeLogger() {
var cfg zap.Config
var err error
@ -16,10 +23,13 @@ func init() {
conf.SetConfigPath("./config")
if err = conf.Load(&cfg, "logging.json"); nil != err {
panic(err)
if logger, err = zap.NewDevelopment(); nil != err {
panic(err)
}
return
}
if Logger, err = cfg.Build(); nil != err {
if logger, err = cfg.Build(); nil != err {
panic(err)
}
}