39 lines
652 B
Go
39 lines
652 B
Go
package logger
|
|
|
|
import (
|
|
"encoding/json"
|
|
"gitlab.finogeeks.club/finclip-backend/mop-middleware-auth/config"
|
|
)
|
|
|
|
var l *Logger
|
|
|
|
func BuildLog(cfg config.Config) {
|
|
time := true
|
|
file := true
|
|
debug := cfg.DebugLog
|
|
trace := cfg.TraceLog
|
|
colors := true
|
|
pid := false
|
|
|
|
if cfg.LogFile == "" {
|
|
l = NewStdLogger(time, file, debug, trace, colors, pid)
|
|
} else {
|
|
l = NewFileLogger(cfg.LogFile, time, file, debug, trace, pid)
|
|
}
|
|
}
|
|
|
|
func GetLogger() *Logger {
|
|
return l
|
|
}
|
|
|
|
type Fields map[string]interface{}
|
|
|
|
func IJS(obj Fields) string {
|
|
jsonBytes, err := json.MarshalIndent(obj, "", " ")
|
|
if err == nil {
|
|
return string(jsonBytes)
|
|
}
|
|
|
|
return ""
|
|
}
|