func InitLogger() {
loggerMgr, err := zap.NewProduction()
if err != nil {
log.Println("error")
}
defer loggerMgr.Sync()
logger := loggerMgr.Sugar()
logger.Error("START!")
}
结果
{"level":"error","ts":1635248463.347698,"caller":"cgw-go-utils/main.go:36","msg":"START!","stacktrace":"main.raiseError \n\t/Users/I053322/dev/repo/cgw-go-utils/main.go:36\nmain.main\n\t/Users/I053322/dev/repo/cgw-go-utils/main.go :22\nruntime.main\n\t/usr/local/opt/go/libexec/src/runtime/proc.go:225"}
我想得到逃避的结果
{"level":"error","ts":1635248463.347698,"caller":"cgw-go-utils/main.go:36","msg":"START!","stacktrace":"main.raiseError
/Users/I053322/dev/repo/cgw-go-utils/main.go:36
main.main
/Users/I053322/dev/repo/cgw-go-utils/main.go:22
runtime.main
/usr/local/opt/go/libexec/src/runtime/proc.go:225"}