Skip to content

Commit 89f37c2

Browse files
pohlyk8s-publishing-bot
authored andcommitted
enhance and fix log calls
Some of these changes are cosmetic (repeatedly calling klog.V instead of reusing the result), others address real issues: - Logging a message only above a certain verbosity threshold without recording that verbosity level (if klog.V().Enabled() { klog.Info... }): this matters when using a logging backend which records the verbosity level. - Passing a format string with parameters to a logging function that doesn't do string formatting. All of these locations where found by the enhanced logcheck tool from kubernetes/klog#297. In some cases it reports false positives, but those can be suppressed with source code comments. Kubernetes-commit: edffc700a43e610f641907290a5152ca593bad79
1 parent 57e5b23 commit 89f37c2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

‎logs/json/json_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func TestZapLoggerInfo(t *testing.T) {
6565
var buffer bytes.Buffer
6666
writer := zapcore.AddSync(&buffer)
6767
sampleInfoLogger, _ := NewJSONLogger(writer, nil, nil)
68+
// nolint:logcheck // The linter cannot and doesn't need to check the key/value pairs.
6869
sampleInfoLogger.Info(data.msg, data.keysValues...)
6970
logStr := buffer.String()
7071

0 commit comments

Comments
 (0)