Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ktesting/testinglogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (l tlogger) Info(level int, msg string, kvList ...interface{}) {
}

func (l tlogger) Enabled(level int) bool {
return l.shared.config.vstate.Enabled(verbosity.Level(level), 1)
return l.shared.config.vstate.Enabled(verbosity.Level(level), l.shared.callDepth+1)
}

func (l tlogger) Error(err error, msg string, kvList ...interface{}) {
Expand Down
21 changes: 19 additions & 2 deletions ktesting/testinglogger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,25 @@ func TestInfo(t *testing.T) {
}

func TestCallDepth(t *testing.T) {
logger := ktesting.NewLogger(t, ktesting.NewConfig())
logger.Info("hello world")
module := "testinglogger_test"
level := 10
config := ktesting.NewConfig()
if err := config.VModule().Set(fmt.Sprintf("%s=%d", module, level)); err != nil {
t.Fatalf("error setting vmodule: %v", err)
}

var buffer logToBuf
logger := ktesting.NewLogger(&buffer, config)

logger.V(level).Info("hello world")
expectedOutput := `Ixxx hello world
`

actual := buffer.String()
actual = headerRe.ReplaceAllString(actual, `${1}xxx `)
if actual != expectedOutput {
t.Errorf("Expected:\n%sActual:\n%s\n", expectedOutput, actual)
}
}

type logToBuf struct {
Expand Down
Loading