-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes for PR #280, refactoring, textlogger, unit test #287
Commits on Feb 14, 2022
-
README.md: clarify API stability
We need the ability to make experimental changes without new definitions immediately becoming part of the stable v2 API.
Configuration menu - View commit details
-
Copy full SHA for 10888e7 - Browse repository at this point
Copy the full SHA 10888e7View commit details -
test: unified testing of structured logging
The new test cases are applied to structured logging calls in klog and the stand-alone klogr logger with output through klog. The output is expected to be the same.
Configuration menu - View commit details
-
Copy full SHA for 7cad178 - Browse repository at this point
Copy the full SHA 7cad178View commit details -
test: add systematic testing of all klog functions
klog has a lot of functions, but not all of them are covered with unit tests. Only a few check stack unwinding. This new test is designed to: - check stack unwinding for all functions - check the difference between fmt.Print and fmt.Println (only the latter inserts spaces between strings) - check the output with and without a Logger This therefore covers bugs in kubernetes#280: - depth was not passed on to Logger - ErrorlnDepth and WarninglnDepth used fmt.Print instead of fmt.Println
Configuration menu - View commit details
-
Copy full SHA for 5a670a2 - Browse repository at this point
Copy the full SHA 5a670a2View commit details -
fix for off-by-one stack unwinding
kubernetes#280 turned println and printf into wrapper functions, but the underlying *Depth functions kept passing the same 0 depth to l.output and thus any logr.Logger. That off-by-one error broke JSON tests in Kubernetes, luckily well before any of the PR went into a release. It would be nice to have regression testing for this in klog, but we cannot depend on a Logger which does stack unwinding in the code, so the only thing that could be done is some kind of GitHub action which combines klog with some external logger. The depth=1 in println is also not covered by unit tests, but seems to be correct based on the JSON tests.
Configuration menu - View commit details
-
Copy full SHA for 51711a3 - Browse repository at this point
Copy the full SHA 51711a3View commit details -
kubernetes#280 added several new functions and didn't quite get the print vs println difference right: the corresponding non-Depth functions use fmt.Println and the Depth versions should do the same.
Configuration menu - View commit details
-
Copy full SHA for 5deb037 - Browse repository at this point
Copy the full SHA 5deb037View commit details -
The implementation of V is performance critical: it may get called frequently on hot code paths and will be responsible for all of the logging overhead when the log messages then do not need to be formatted.
Configuration menu - View commit details
-
Copy full SHA for 0893658 - Browse repository at this point
Copy the full SHA 0893658View commit details -
internal: stand-alone implementation of -v and -verbose
This will be needed for Logger implementations that want to emulate the traditional verbosity check in klog. The original code in klog.go intentionally doesn't get modified, for two reasons: - avoid the risk of regressions - an attempt to do so showed that V became slower (extra calls, more parameters, etc.)
Configuration menu - View commit details
-
Copy full SHA for ec9f867 - Browse repository at this point
Copy the full SHA ec9f867View commit details -
internal: move key/value handling into stand-alone package
This makes it possible to reuse the klog output formatting in logr.Logger implementations.
Configuration menu - View commit details
-
Copy full SHA for 69f6111 - Browse repository at this point
Copy the full SHA 69f6111View commit details -
split out buffer helpers and severity definition
This will enable writing Logger implementations which reproduce the traditional klog header.
Configuration menu - View commit details
-
Copy full SHA for c734dc7 - Browse repository at this point
Copy the full SHA c734dc7View commit details -
klogr: report missing values with "(MISSING)"
klogr had a special value for a missing value in a key/value pair, so the intention probably was to use that as replacement, the same way as klog does it. But because of a bug in the code which removed duplicates, it treated a missing value like nil. Now the behavior is consistent with klog.
Configuration menu - View commit details
-
Copy full SHA for cda3be7 - Browse repository at this point
Copy the full SHA cda3be7View commit details -
klogr: improve handling of missing value in WithValues
This is invalid: logger.WithValue("keyWithoutValue").WithValue("anotherKeyWithoutValue") Because it concatenated key/values without checking, klogr treated this like: logger.WithValue("keyWithoutValue", "anotherKeyWithoutValue") Now the parameters are checked and a "(MISSING)" is appended as in the other cases where a missing value is detected.
Configuration menu - View commit details
-
Copy full SHA for 5938b0a - Browse repository at this point
Copy the full SHA 5938b0aView commit details -
textlogger: add logger which emulates the traditional output
In contrast to klogr, the formatting and printing is handled entirely by this logger without depending on klog.go. The intention is to use this in two ways: - for testing of SetLogger - as simpler text logger in Kubernetes for contextual logging
Configuration menu - View commit details
-
Copy full SHA for 71ac98f - Browse repository at this point
Copy the full SHA 71ac98fView commit details