diff --git a/logging.go b/logging.go index 6b140a2..b7dd865 100644 --- a/logging.go +++ b/logging.go @@ -1,6 +1,8 @@ package logging import ( + "log" + "git.loafle.net/commons_go/config" "go.uber.org/zap" @@ -10,26 +12,27 @@ var logger *zap.Logger func Logger() *zap.Logger { if nil == logger { - initializeLogger() + log.Panicf("Logger is not initialized") } return logger } -func initializeLogger() { +func InitializeLogger(configPath string) { var cfg zap.Config var err error conf := config.New() - conf.SetConfigPath("./config") - if err = conf.Load(&cfg, "logging.json"); nil != err { + if err = conf.Load(&cfg, configPath); nil != err { + log.Printf("Loading of logger config has been failed [%v]", err) if logger, err = zap.NewDevelopment(); nil != err { - panic(err) + log.Panicf("Building of logger configp[Development] has been failed [%v]", err) } + log.Printf("Logger has been initialized as development mode") return } if logger, err = cfg.Build(); nil != err { - panic(err) + log.Panicf("Building of logger config[%s] has been failed [%v]", configPath, err) } }