update gomod/str

This commit is contained in:
bryanqiu 2022-10-12 21:58:20 +08:00
parent d68105842d
commit 813dc81ea1
2 changed files with 11 additions and 8 deletions

2
go.mod
View File

@ -1,3 +1,5 @@
module qoobing.com/gomod/log module qoobing.com/gomod/log
go 1.16 go 1.16
require qoobing.com/gomod/str v1.0.0

17
log.go
View File

@ -9,19 +9,20 @@ import (
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"qoobing.com/gomod/str"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
"strings" "strings"
"sync" "sync"
"time" "time"
"qoobing.com/gomod/str"
) )
var ( var (
glogger *log.Logger = nil glogger *log.Logger = nil
once sync.Once = sync.Once{} once sync.Once = sync.Once{}
mylogger *Logger = nil mylogger *Logger = nil
modellogs map[string]*Logger = map[string]*Logger{} modellogs map[string]*Logger = map[string]*Logger{}
) )
const ErrLogPanic = "~~~~panic~~~~~~" const ErrLogPanic = "~~~~panic~~~~~~"
@ -63,9 +64,9 @@ func New(model string) (logger *Logger) {
if model == "" { if model == "" {
model = "undefine" model = "undefine"
} }
if _, ok := modellogs[model]; ok{ if _, ok := modellogs[model]; ok {
return modellogs[model] return modellogs[model]
}else{ } else {
modellogs[model] = &Logger{model: model, logger: glogger} modellogs[model] = &Logger{model: model, logger: glogger}
return modellogs[model] return modellogs[model]
} }
@ -250,7 +251,7 @@ func initlog() {
glogger = openlog(LOGFILENAME) glogger = openlog(LOGFILENAME)
mylogger = New("system") mylogger = New("system")
for _, l := range modellogs{ for _, l := range modellogs {
l.logger = glogger l.logger = glogger
} }
} }