From 813dc81ea1f0c04f9ce98f3a00f63ccdf378728c Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Wed, 12 Oct 2022 21:58:20 +0800 Subject: [PATCH] update gomod/str --- go.mod | 2 ++ log.go | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index ec69711..b02a7b4 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module qoobing.com/gomod/log go 1.16 + +require qoobing.com/gomod/str v1.0.0 diff --git a/log.go b/log.go index 0e534a0..686390d 100644 --- a/log.go +++ b/log.go @@ -9,19 +9,20 @@ import ( "log" "os" "path/filepath" - "qoobing.com/gomod/str" "runtime" "runtime/debug" "strings" "sync" "time" + + "qoobing.com/gomod/str" ) var ( - glogger *log.Logger = nil - once sync.Once = sync.Once{} - mylogger *Logger = nil - modellogs map[string]*Logger = map[string]*Logger{} + glogger *log.Logger = nil + once sync.Once = sync.Once{} + mylogger *Logger = nil + modellogs map[string]*Logger = map[string]*Logger{} ) const ErrLogPanic = "~~~~panic~~~~~~" @@ -63,9 +64,9 @@ func New(model string) (logger *Logger) { if model == "" { model = "undefine" } - if _, ok := modellogs[model]; ok{ + if _, ok := modellogs[model]; ok { return modellogs[model] - }else{ + } else { modellogs[model] = &Logger{model: model, logger: glogger} return modellogs[model] } @@ -250,7 +251,7 @@ func initlog() { glogger = openlog(LOGFILENAME) mylogger = New("system") - for _, l := range modellogs{ + for _, l := range modellogs { l.logger = glogger } }