logging/logging.go
crusader 851f39a83d ing
2017-11-09 15:09:57 +09:00

36 lines
519 B
Go

package logging
import (
"git.loafle.net/commons_go/config"
"go.uber.org/zap"
)
var logger *zap.Logger
func Logger() *zap.Logger {
if nil == logger {
initializeLogger()
}
return logger
}
func initializeLogger() {
var cfg zap.Config
var err error
conf := config.New()
conf.SetConfigPath("./config")
if err = conf.Load(&cfg, "logging.json"); nil != err {
if logger, err = zap.NewDevelopment(); nil != err {
panic(err)
}
return
}
if logger, err = cfg.Build(); nil != err {
panic(err)
}
}