-
Notifications
You must be signed in to change notification settings - Fork 225
Comparing changes
Open a pull request
base repository: kubernetes/klog
base: v2.100.1
head repository: kubernetes/klog
compare: v2.110.1
- 20 commits
- 56 files changed
- 4 contributors
Commits on May 17, 2023
-
fix: SetLogger via klog.SetLogger will output an unexpected newline
klog always adds a newline to the msg. klog will work fine without klog. Set logr with klog.SetLogger, and klog will also pass the msg with the newline added to logr, which will result in an accidental newline being added. step1: klog.Info("hello world") step2: msg = msg + "\n" step3: stdout.W(msg) or logr.Info(msg[:len(msg)-1]) fix #370 Signed-off-by: aimuz <mr.imuz@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 1e2789b - Browse repository at this point
Copy the full SHA 1e2789bView commit details
Commits on May 20, 2023
-
Merge pull request #378 from aimuz/fix-370
fix: SetLogger via klog.SetLogger will output an unexpected newline
Configuration menu - View commit details
-
Copy full SHA for 5ac9b76 - Browse repository at this point
Copy the full SHA 5ac9b76View commit details
Commits on May 27, 2023
-
Signed-off-by: lowang_bh <lhui_wang@163.com>
Configuration menu - View commit details
-
Copy full SHA for 6c35c6a - Browse repository at this point
Copy the full SHA 6c35c6aView commit details
Commits on May 30, 2023
-
Merge pull request #379 from lowang-bh/fixWarning
resolve comments warning
Configuration menu - View commit details
-
Copy full SHA for ff82b97 - Browse repository at this point
Copy the full SHA ff82b97View commit details
Commits on Jun 1, 2023
-
golangci-lint v1.52.2 in its default configuration pointed out several issues that are worth fixing: internal/verbosity/verbosity_test.go:26:18: Error return value of `vs.verbosity.Set` is not checked (errcheck) vs.verbosity.Set("2") ^ internal/verbosity/verbosity_test.go:41:16: Error return value of `vs.vmodule.Set` is not checked (errcheck) vs.vmodule.Set("verbosity_test=2") ^ internal/verbosity/verbosity_test.go:84:16: Error return value of `vs.vmodule.Set` is not checked (errcheck) vs.vmodule.Set(pat) ^ internal/verbosity/verbosity.go:291:2: S1017: should replace this if statement with an unconditional strings.TrimSuffix (gosimple) if strings.HasSuffix(file, ".go") { ^ textlogger/options.go:140:19: Error return value of `(flag.Value).Set` is not checked (errcheck) c.Verbosity().Set(strconv.FormatInt(int64(c.co.verbosityDefault), 10)) ^ textlogger/textlogger.go:137:26: Error return value of `l.config.co.output.Write` is not checked (errcheck) l.config.co.output.Write(b.Bytes()) ^ textlogger/textlogger.go:141:26: Error return value of `l.config.co.output.Write` is not checked (errcheck) l.config.co.output.Write(data) ^ ktesting/options.go:163:18: Error return value of `(flag.Value).Set` is not checked (errcheck) c.vstate.V().Set(strconv.FormatInt(int64(c.co.verbosityDefault), 10)) ^ klogr/calldepth-test/call_depth_main_test.go:21:22: Error return value of `flag.CommandLine.Set` is not checked (errcheck) flag.CommandLine.Set("v", "10") ^ klogr/calldepth-test/call_depth_main_test.go:22:22: Error return value of `flag.CommandLine.Set` is not checked (errcheck) flag.CommandLine.Set("skip_headers", "false") ^ klogr/calldepth-test/call_depth_main_test.go:23:22: Error return value of `flag.CommandLine.Set` is not checked (errcheck) flag.CommandLine.Set("logtostderr", "false") ^ klog.go:903:34: Error return value of `(io.Writer).Write` is not checked (errcheck) l.file[severity.InfoLog].Write(data) ^ klog.go:913:20: Error return value of `(io.Writer).Write` is not checked (errcheck) l.file[s].Write(data) ^ klog.go:917:37: Error return value of `(io.Writer).Write` is not checked (errcheck) l.file[severity.FatalLog].Write(data) ^ klog.go:952:12: Error return value of `f.Write` is not checked (errcheck) f.Write(trace) ^ klog.go:1208:13: Error return value of `file.Sync` is not checked (errcheck) file.Sync() // ignore error ^ klog_file.go:113:14: Error return value of `os.Symlink` is not checked (errcheck) os.Symlink(name, symlink) // ignore err ^ klog_test.go:328:23: Error return value of `logging.verbosity.Set` is not checked (errcheck) logging.verbosity.Set("2") ^ klog_test.go:343:21: Error return value of `logging.vmodule.Set` is not checked (errcheck) logging.vmodule.Set("klog_test=2") ^ klog_test.go:367:21: Error return value of `logging.vmodule.Set` is not checked (errcheck) logging.vmodule.Set("notthisfile=2") ^ klog_test.go:459:21: Error return value of `logging.vmodule.Set` is not checked (errcheck) logging.vmodule.Set(pat) ^ klog_test.go:807:23: Error return value of `logging.verbosity.Set` is not checked (errcheck) logging.verbosity.Set("0") ^ klog_test.go:878:9: Error return value of `fs1.Set` is not checked (errcheck) fs1.Set("log_dir", "/test1") ^ klog_test.go:879:9: Error return value of `fs1.Set` is not checked (errcheck) fs1.Set("log_file_max_size", "1") ^ klog_test.go:885:9: Error return value of `fs2.Set` is not checked (errcheck) fs2.Set("log_file_max_size", "2048") ^ klog_test.go:1173:23: Error return value of `logging.verbosity.Set` is not checked (errcheck) logging.verbosity.Set("2") ^ klogr.go:35:2: field `level` is unused (unused) level int ^ klog.go:1287:2: S1017: should replace this if statement with an unconditional strings.TrimSuffix (gosimple) if strings.HasSuffix(file, ".go") { ^ klog.go:521:2: S1001: should use copy(to, from) instead of a loop (gosimple) for i := range s.vmodule.filter { ^ klog_test.go:79:2: S1001: should copy arrays using assignment instead of using a loop (gosimple) for i, w := range writers { ^ klogr/klogr.go:118:16: Error return value of `encoder.Encode` is not checked (errcheck) encoder.Encode(value) ^ klogr/klogr_test.go:208:8: Error return value of `fs.Set` is not checked (errcheck) fs.Set("skip_headers", "true") ^ klogr/klogr.go:119:27: S1030: should use buffer.String() instead of string(buffer.Bytes()) (gosimple) return strings.TrimSpace(string(buffer.Bytes())) ^ ktesting/testinglogger_test.go:176:8: Error return value of `fs.Set` is not checked (errcheck) fs.Set("alsologtostderr", "false") ^ ktesting/testinglogger_test.go:177:8: Error return value of `fs.Set` is not checked (errcheck) fs.Set("logtostderr", "false") ^ internal/buffer/buffer.go:40:2: field `next` is unused (unused) next *Buffer ^ internal/clock/clock.go:122:9: SA1015: using time.Tick leaks the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (staticcheck) return time.Tick(d) ^ exit_test.go:31:16: Error return value of `flag.Set` is not checked (errcheck) defer flag.Set("skip_headers", "false") ^ format_test.go:46:5: S1003: should use strings.Contains(str, "kind is config") instead (gosimple) if strings.Index(str, "kind is config") >= 0 { ^
Configuration menu - View commit details
-
Copy full SHA for a4f9060 - Browse repository at this point
Copy the full SHA a4f9060View commit details
Commits on Jun 13, 2023
-
stderrthreshold: fix flag comment
The code is so that the -stderrthreshold gets ignored when -alsologtostderr=true.
Configuration menu - View commit details
-
Copy full SHA for 3838dbc - Browse repository at this point
Copy the full SHA 3838dbcView commit details -
Merge pull request #376 from pohly/stderr-threshold-docs
stderrthreshold: fix flag comment
Configuration menu - View commit details
-
Copy full SHA for 6632ba5 - Browse repository at this point
Copy the full SHA 6632ba5View commit details
Commits on Oct 23, 2023
-
enable "go vet" checks for parameters
Adding some dead code which calls fmt.Sprintf/Sprint/Sprintln makes "go vet" recognize what kind of parameters the unstructured klog calls take (https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf#hdr-Analyzer_printf). Then it can report incorrect calls like: klog.Infof("%s") // k8s.io/klog/v2.Infof format %s reads arg #1, but call has 0 args klog.Info("%s", "world") // k8s.io/klog/v2.Info call has possible formatting directive %s The same does not work for structured calls like klog.InfoS. logcheck needs to be used for those.
Configuration menu - View commit details
-
Copy full SHA for b394f4b - Browse repository at this point
Copy the full SHA b394f4bView commit details -
testing: bump Go version matrix
Testing with Go 1.17 gets removed because it does not support "go mod vendor -o" and is out of support.
Configuration menu - View commit details
-
Copy full SHA for 6af4ad1 - Browse repository at this point
Copy the full SHA 6af4ad1View commit details -
Merge pull request #390 from pohly/go-vet-print
enable "go vet" checks for parameters
Configuration menu - View commit details
-
Copy full SHA for 61b308a - Browse repository at this point
Copy the full SHA 61b308aView commit details
Commits on Oct 26, 2023
-
promote experimental code to stable
ktesting is heavily used in Kubernetes already for testing. The test package is also used. The textlogger is not used that much yet because it was still experimental (and thus no replacement for normal klog), but it's simple and unlikely to need any breaking API changes.
Configuration menu - View commit details
-
Copy full SHA for 18cdd3a - Browse repository at this point
Copy the full SHA 18cdd3aView commit details -
Merge pull request #392 from pohly/promote-experimental
promote experimental code to stable
Configuration menu - View commit details
-
Copy full SHA for edee20c - Browse repository at this point
Copy the full SHA edee20cView commit details -
In golangci-lint and upstream, revive has replaced golint because golint is no longer maintained. revive finds some more issues that need to be fixed before it can be used: ktesting/testinglogger.go:81:20: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) func (n NopTL) Log(args ...interface{}) {} ^ klogr/klogr_test.go:23:2: redefines-builtin-id: redefinition of the built-in function new (revive) new := func() logr.Logger { switch format { case formatNew: return New() case formatDefault: return NewWithOptions() default: return NewWithOptions(WithFormat(Format(format))) } } internal/clock/testing/fake_clock.go:261:29: unused-parameter: parameter 'd' seems to be unused, consider removing or renaming it as _ (revive) func (*IntervalClock) After(d time.Duration) <-chan time.Time { ^ internal/clock/testing/fake_clock.go:267:32: unused-parameter: parameter 'd' seems to be unused, consider removing or renaming it as _ (revive) func (*IntervalClock) NewTimer(d time.Duration) clock.Timer { ^ internal/clock/testing/fake_clock.go:273:33: unused-parameter: parameter 'd' seems to be unused, consider removing or renaming it as _ (revive) func (*IntervalClock) AfterFunc(d time.Duration, f func()) clock.Timer { ^ textlogger/textlogger.go:148:2: redefines-builtin-id: redefinition of the built-in function new (revive) new := *l ^ textlogger/textlogger.go:157:2: redefines-builtin-id: redefinition of the built-in function new (revive) new := *l ^ textlogger/textlogger.go:91:24: unused-parameter: parameter 'level' seems to be unused, consider removing or renaming it as _ (revive) func (l *tlogger) Info(level int, msg string, kvList ...interface{}) { ^ klog_test.go:2204:2: redefines-builtin-id: redefinition of the built-in function copy (revive) copy := settings.deepCopy() ^ klog_test.go:95:48: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive) func contains(s severity.Severity, str string, t *testing.T) bool { ^ klog_test.go:378:28: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive) func TestSetOutputDataRace(t *testing.T) { ^ klog_test.go:1807:25: unused-parameter: parameter 'level' seems to be unused, consider removing or renaming it as _ (revive) func (l *testLogr) Info(level int, msg string, keysAndValues ...interface{}) { ^ klog_test.go:1828:25: unused-parameter: parameter 'info' seems to be unused, consider removing or renaming it as _ (revive) func (l *testLogr) Init(info logr.RuntimeInfo) {} ^ klog_test.go:1829:28: unused-parameter: parameter 'level' seems to be unused, consider removing or renaming it as _ (revive) func (l *testLogr) Enabled(level int) bool { return true } ^ klog_test.go:1833:34: unused-parameter: parameter 'depth' seems to be unused, consider removing or renaming it as _ (revive) func (l *testLogr) WithCallDepth(depth int) logr.LogSink { return l } ^
Configuration menu - View commit details
-
Copy full SHA for ef25537 - Browse repository at this point
Copy the full SHA ef25537View commit details -
github: run golangci-lint via action
The main advantage is that issues get posted as annotations, which makes them easier to find when looking at a diff for a PR. While at it, golangci-lint gets invoked so that it runs in its default configuration plus the linters that were enabled explicitly before (misspell, gofmt, revive as replacement for golint). It also gets applied to the examples package.
Configuration menu - View commit details
-
Copy full SHA for 1a0dfc5 - Browse repository at this point
Copy the full SHA 1a0dfc5View commit details -
Merge pull request #380 from pohly/golangci-lint-action
golangci-lint action
Configuration menu - View commit details
-
Copy full SHA for b588475 - Browse repository at this point
Copy the full SHA b588475View commit details -
output: handle WithName like zapr does
Previously, all names set via `WithNames` were concatenated with / and added to the main message string as a `<names>: <msg>` prefix. Now klog in all of its incarnations (internal logger in klog, klogr, textlogger) behaves like zapr and adds a "logger" key with the names concatenated by a dot as value. The main advantage, besides consistency, is that code which does a full string match against some message string still works even when contextual logging is enabled and `WithName` is used, at least as long as that code doesn't also match all key/value pairs.
Configuration menu - View commit details
-
Copy full SHA for 009a04a - Browse repository at this point
Copy the full SHA 009a04aView commit details -
Merge pull request #391 from pohly/with-name-output
output: handle WithName like zapr does
Configuration menu - View commit details
-
Copy full SHA for 02e7b69 - Browse repository at this point
Copy the full SHA 02e7b69View commit details
Commits on Oct 27, 2023
-
LogSink.Enabled is sensitive to stack unwinding. logr v1.2.0 got this wrong by calling LogSink.Enabled at different depths for Logger.Info and Logger.Enabled, therefore this test fails with that version. logr v1.3.0 changes the behavior to the more sane "LogSink.Enabled needs to skip one level, regardless where it is called". The Discard log sink implementation changed such that a discard logger doesn't have a sink at all anymore. Go < 1.18 is no longer supported by logr.
Configuration menu - View commit details
-
Copy full SHA for cc856bb - Browse repository at this point
Copy the full SHA cc856bbView commit details
Commits on Oct 30, 2023
-
When compiled with Go >= 1.21, special support for log/slog gets enabled automatically: - The formatting of key/value pairs supports slog.Value and slog.LogValuer, regardless of where those come from. - A slog.GroupValue is formatted as a JSON object. - The logger returned by klog.Background() and the textlogger support usage as a backend for the slog API, via slogr.NewSlogHandler, with builtin support for handling a slog.Record. However, -vmodule does not work when called like that because stack unwinding during the Enabled check finds the wrong source code. - KObj (= ObjectRef) and the type behind KObjSlice support the slog.LogValuer interface and thus get formatted properly by slog backends. The klogr package doesn't get updated. It shouldn't be used anymore. To make that clearer, it gets marked as "deprecated". Examples demonstrate the resulting output. That output has to be exactly the same when used as test, so pid and time get set to fixed values.
Configuration menu - View commit details
-
Copy full SHA for 44eadc3 - Browse repository at this point
Copy the full SHA 44eadc3View commit details
Commits on Oct 31, 2023
-
Merge pull request #384 from pohly/slog
slog support + logr 1.3.0 update
Configuration menu - View commit details
-
Copy full SHA for e3f75b8 - Browse repository at this point
Copy the full SHA e3f75b8View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff v2.100.1...v2.110.1