-
Notifications
You must be signed in to change notification settings - Fork 218
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
Fix the log duplication issue for --log-file #78
Conversation
benchmark with "fix"
benchmark without the "fix"
|
/approve cancel |
klog.go
Outdated
|
||
if logging.logFile != "" { | ||
if l.file[infoLog] == nil { | ||
if err := l.createFiles(s); err != nil { |
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.
should this be l.createFiles(infoLog)
?
i don't know the details of the duplication issue, but does logging.logFile
imply infoLog
severity only?
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.
Fixed @neolit123. added some comments to clarify what we are doing
5dd7e85
to
e07c880
Compare
/assign @tallclair @yuwenma @tallclair can you please review since both of you worked on the previous attempt? (in kubernetes/kubernetes#78466) |
when we use a `log-file`, all the items in l.file array point to the same file. we are currently using a switch statement with fallthrough which ends up logging the same line multiple times. So check if we are using a `log-file` and just write the data once. Change-Id: I3396558f487daf9db2c5e21e29a7a6bee618d64a
e07c880
to
bf4884f
Compare
@dims The PR lgtm. The only concern I have is that: Even if user provides --log-file flag, they should still be able to use --alsologtostderr flag to require standard output. This requires storing logs individually by severity level. Also, in such case users should be able to use --stderrthreshold to change the severity level of the standard output (e.g. if stderrthreshold is warning, all logs in warning and above warning will be printed in the stdout). The above feature is no longer available after this PR goes in. Is this what we want? If so, can you add a docstring for alsologtostderr and stderrthreshold flags to explain this behavior? |
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.
/lgtm
I could have sworn I reviewed a very similar change before, but don't know what happened to it...
if logging.logFile != "" { | ||
// Since we are using a single log file, all of the items in l.file array | ||
// will point to the same file, so just use one of them to write data. | ||
if l.file[infoLog] == nil { |
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.
nit: can we declare a constant to make this more explicit?
const singleFileLog = infoLog
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tallclair The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@yuwenma I don't understand your comment - it looks like the stderr output happens before these changes? Or were you commenting on an older version of this PR? |
yeah, i was referring to a old change. /lgtm |
What this PR does / why we need it:
when we use a
log-file
, all the items in l.file array point to thesame file. we are currently using a switch statement with fallthrough
which ends up logging the same line multiple times. So check if we are
using a
log-file
and just write the data once.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
Release note: