Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
structured logging: replacing Fatal/Exit/etc. without loss of flushing #303
structured logging: replacing Fatal/Exit/etc. without loss of flushing #303
Changes from all commits
56b8a4e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are end users able to modify these directly? they shouldn't right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a bit need for modifying it, but also no good reason why we shouldn't allow it. Being able to modify them is mostly (just?) useful in tests.
This timeout can become a constant.
The OsExit function has to be a variable, but we could unexport it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking of OsExit, if we allow modifying it, should Fatal and friends also call it?
There is a feature request where someone is asking for Fatal to not call os.Exit. We cannot change the default behavior and not call os.Exit (that behavior is part of the stable API), but if we export OsExit and use it in Fatal, then someone who knows his application can perhaps change it into a function which panics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a version that uses OsExit everywhere instead of calling os.Exit directly and also updated the comments: https://github.com/kubernetes/klog/compare/dbc5aa051e765a4216e0fb89e0b54fae92ad8ab0..56b8a4ea35ba0fc3be9fc82182e71c2f0116adc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we can't have a TestFlushAndExit (Similar to functions in TestErrorS in klog_test.go) ?
We can check against the following format.
format: "\"exiting...\"\nos.Exit(10)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have such a test function, but an example is more useful:
go test