diff --git a/examples/output_test/output_test.go b/examples/output_test/output_test.go index a6ef0abb2..0624e3a74 100644 --- a/examples/output_test/output_test.go +++ b/examples/output_test/output_test.go @@ -21,7 +21,6 @@ package output_test import ( "io" - "strings" "testing" "github.com/go-logr/logr" @@ -112,10 +111,6 @@ func TestKlogrStackText(t *testing.T) { // records that. func TestKlogrStackZapr(t *testing.T) { mapping := test.ZaprOutputMappingIndirect() - for key, value := range mapping { - // BUG (https://github.com/kubernetes/klog/issues/294): verbosity is lost - mapping[key] = strings.ReplaceAll(value, `"v":9`, `"v":0`) - } // klogr doesn't warn about invalid KVs and just inserts // "(MISSING)". diff --git a/klogr/klogr.go b/klogr/klogr.go index 02433e844..8206c10d4 100644 --- a/klogr/klogr.go +++ b/klogr/klogr.go @@ -122,13 +122,13 @@ func (l klogger) Info(level int, msg string, kvList ...interface{}) { trimmed := serialize.TrimDuplicates(l.values, kvList) fixedStr := flatten(trimmed[0]...) userStr := flatten(trimmed[1]...) - klog.InfoDepth(l.callDepth+1, l.prefix, " ", msgStr, " ", fixedStr, " ", userStr) + klog.V(klog.Level(level)).InfoDepth(l.callDepth+1, l.prefix, " ", msgStr, " ", fixedStr, " ", userStr) case FormatKlog: trimmed := serialize.TrimDuplicates(l.values, kvList) if l.prefix != "" { msg = l.prefix + ": " + msg } - klog.InfoSDepth(l.callDepth+1, msg, append(trimmed[0], trimmed[1]...)...) + klog.V(klog.Level(level)).InfoSDepth(l.callDepth+1, msg, append(trimmed[0], trimmed[1]...)...) } }