From e489d577919638d9202b2618c6524cac8362942e Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 19 Sep 2017 15:00:20 +0900 Subject: [PATCH] ing --- glide.yaml | 3 +-- logging.go | 31 +++++++------------------------ 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/glide.yaml b/glide.yaml index a8c23f1..2650089 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,5 +1,4 @@ package: git.loafle.net/commons_go/logging import: -- package: go.uber.org/zap - version: v1.5.0 - package: git.loafle.net/commons_go/config +- package: go.uber.org/zap diff --git a/logging.go b/logging.go index e1834d0..d2f8c64 100644 --- a/logging.go +++ b/logging.go @@ -1,42 +1,25 @@ package logging import ( - "encoding/json" - "git.loafle.net/commons_go/config" "go.uber.org/zap" ) -type loggerKeyType int - -const loggerKey loggerKeyType = iota - var Logger *zap.Logger func init() { - conf := config.New() - conf.SetConfigName("logging") - conf.SetConfigType("json") - conf.AddConfigPath(".") - conf.AddConfigPath("./config") - err := conf.ReadInConfig() - if nil != err { - panic(err) - } - - buf, err := conf.Marshal("json") - if err != nil { - panic(err) - } var cfg zap.Config - if err = json.Unmarshal(buf, &cfg); err != nil { + var err error + + conf := config.New() + conf.SetConfigPath("./config") + + if err = conf.Load(&cfg, "logging.json"); nil != err { panic(err) } - Logger, err = cfg.Build() - if err != nil { + if Logger, err = cfg.Build(); nil != err { panic(err) } - }