Skip to content

Commit

Permalink
textlogger: fix vmodule support
Browse files Browse the repository at this point in the history
When Logger.Info called Enabled, the wrong number of stack frames were skipped.

A unit test for this will follow.
  • Loading branch information
pohly authored and dims committed Jan 19, 2023
1 parent 34a9807 commit 70aa795
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion textlogger/textlogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func (l *tlogger) WithCallDepth(depth int) logr.LogSink {
}

func (l *tlogger) Enabled(level int) bool {
return l.config.Enabled(verbosity.Level(level), 1)
// Skip this function and the Logger.Info call, then
// also any additional stack frames from WithCallDepth.
return l.config.Enabled(verbosity.Level(level), 2+l.callDepth)
}

func (l *tlogger) Info(level int, msg string, kvList ...interface{}) {
Expand Down

0 comments on commit 70aa795

Please sign in to comment.