From cc5ba36df84ef62c6a1d810d983a90d8b0f7380f Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 20 Mar 2018 23:44:19 +0900 Subject: [PATCH] ing --- logging.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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) } }