diff --git a/log.go b/log.go index 4779e8cc..66f4ade5 100644 --- a/log.go +++ b/log.go @@ -392,7 +392,9 @@ func (l *Logger) Log() *Event { // Arguments are handled in the manner of fmt.Print. func (l *Logger) Print(v ...interface{}) { if e := l.Debug(); e.Enabled() { + ContextCallerSkipFrameCount++ e.Msg(fmt.Sprint(v...)) + ContextCallerSkipFrameCount-- } } @@ -400,7 +402,9 @@ func (l *Logger) Print(v ...interface{}) { // Arguments are handled in the manner of fmt.Printf. func (l *Logger) Printf(format string, v ...interface{}) { if e := l.Debug(); e.Enabled() { + ContextCallerSkipFrameCount++ e.Msg(fmt.Sprintf(format, v...)) + ContextCallerSkipFrameCount-- } } @@ -412,7 +416,9 @@ func (l Logger) Write(p []byte) (n int, err error) { // Trim CR added by stdlog. p = p[0 : n-1] } + ContextCallerSkipFrameCount++ l.Log().Msg(string(p)) + ContextCallerSkipFrameCount-- return } diff --git a/log/log.go b/log/log.go index b96f1c14..d0419252 100644 --- a/log/log.go +++ b/log/log.go @@ -114,13 +114,17 @@ func Log() *zerolog.Event { // Print sends a log event using debug level and no extra field. // Arguments are handled in the manner of fmt.Print. func Print(v ...interface{}) { + zerolog.ContextCallerSkipFrameCount++ Logger.Print(v...) + zerolog.ContextCallerSkipFrameCount-- } // Printf sends a log event using debug level and no extra field. // Arguments are handled in the manner of fmt.Printf. func Printf(format string, v ...interface{}) { + zerolog.ContextCallerSkipFrameCount++ Logger.Printf(format, v...) + zerolog.ContextCallerSkipFrameCount-- } // Ctx returns the Logger associated with the ctx. If no logger