42 lines
637 B
Go
42 lines
637 B
Go
package logger
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"finclip-app-manager/infrastructure/config"
|
|
)
|
|
|
|
var l *Logger
|
|
|
|
func init() {
|
|
cfg := config.GetConfig()
|
|
|
|
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 ""
|
|
}
|