# HG changeset patch # User Sascha L. Teichmann # Date 1632154178 -7200 # Node ID b4f59aef3f9e6e0fb59331226b71ccca969a570a # Parent 09346efa7f699ed88b09f1ee059c9aaf99384b39 Use correct calldepth for logging. diff -r 09346efa7f69 -r b4f59aef3f9e pkg/log/log.go --- a/pkg/log/log.go Mon Sep 20 18:02:09 2021 +0200 +++ b/pkg/log/log.go Mon Sep 20 18:09:38 2021 +0200 @@ -43,6 +43,8 @@ lg.SetFlags(lg.LstdFlags | lg.Lshortfile) } +const callDepth = 2 + func SetupLog(filename string, perm os.FileMode) error { f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, perm) if err != nil { @@ -117,90 +119,90 @@ func Tracef(f string, args ...interface{}) { if TraceLogLevel >= GetLogLevel() { s := fmt.Sprintf(f, args...) - lg.Output(4, "[TRACE] "+s) + lg.Output(callDepth, "[TRACE] "+s) } } func Traceln(s string) { if TraceLogLevel >= GetLogLevel() { - lg.Output(4, "[TRACE] "+s) + lg.Output(callDepth, "[TRACE] "+s) } } func Debugf(f string, args ...interface{}) { if DebugLogLevel >= GetLogLevel() { s := fmt.Sprintf(f, args...) - lg.Output(4, "[DEBUG] "+s) + lg.Output(callDepth, "[DEBUG] "+s) } } func Debugln(s string) { if DebugLogLevel >= GetLogLevel() { - lg.Output(4, "[DEBUG] "+s) + lg.Output(callDepth, "[DEBUG] "+s) } } func Infof(f string, args ...interface{}) { if InfoLogLevel >= GetLogLevel() { s := fmt.Sprintf(f, args...) - lg.Output(4, "[INFO] "+s) + lg.Output(callDepth, "[INFO] "+s) } } func Infoln(s string) { if InfoLogLevel >= GetLogLevel() { - lg.Output(4, "[INFO] "+s) + lg.Output(callDepth, "[INFO] "+s) } } func Warnf(f string, args ...interface{}) { if WarnLogLevel >= GetLogLevel() { s := fmt.Sprintf(f, args...) - lg.Output(4, "[WARN] "+s) + lg.Output(callDepth, "[WARN] "+s) } } func Warnln(s string) { if WarnLogLevel >= GetLogLevel() { - lg.Output(4, "[WARN] "+s) + lg.Output(callDepth, "[WARN] "+s) } } func Errorf(f string, args ...interface{}) { if ErrorLogLevel >= GetLogLevel() { s := fmt.Sprintf(f, args...) - lg.Output(4, "[ERROR] "+s) + lg.Output(callDepth, "[ERROR] "+s) } } func Errorln(s string) { if ErrorLogLevel >= GetLogLevel() { - lg.Output(4, "[ERROR] "+s) + lg.Output(callDepth, "[ERROR] "+s) } } func Fatalf(f string, args ...interface{}) { if FatalLogLevel >= GetLogLevel() { s := fmt.Sprintf(f, args...) - lg.Output(4, "[FATAL] "+s) + lg.Output(callDepth, "[FATAL] "+s) os.Exit(1) } } func Fatalln(s string) { if FatalLogLevel >= GetLogLevel() { - lg.Output(4, "[FATAL] "+s) + lg.Output(callDepth, "[FATAL] "+s) os.Exit(1) } } func Panicf(f string, args ...interface{}) { s := fmt.Sprintf(f, args...) - lg.Output(4, "[PANIC] "+s) + lg.Output(callDepth, "[PANIC] "+s) panic(s) } func Panicln(s string) { - lg.Output(4, "[PANIC] "+s) + lg.Output(callDepth, "[PANIC] "+s) panic(s) }