-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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: Normal logs should not go to stderr (#3491) #5574
Conversation
6b8627f
to
abf4eb9
Compare
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.
Hi!
I think it will be better to apply new logging logic to argocd-dex too but keep cli (argocd and argocd-util) not touched
Also, it looks like e2e tests will not fail if cli will keep sending logs to stderr
abf4eb9
to
0ed218c
Compare
Codecov Report
@@ Coverage Diff @@
## master #5574 +/- ##
==========================================
+ Coverage 40.88% 41.01% +0.12%
==========================================
Files 146 146
Lines 19571 19612 +41
==========================================
+ Hits 8002 8043 +41
Misses 10455 10455
Partials 1114 1114
Continue to review full report at Codecov.
|
Signed-off-by: iam-veeramalla <[email protected]>
0ed218c
to
57637c0
Compare
@jannfis @mnacharov Can you have a relook at this ? I moved away from the logrus hooks approach as it was duplicating every log and degrading the performance. I wrote a simple wrapper as suggested in the logrus community by the maintainers. However, we have to figure out a new package if this change does not seem very efficient. |
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.
Looks fine, but I would suggest some tweaks
// SetLogOutput sets log output to different streams | ||
func SetLogOutput() { | ||
log.SetOutput(&LogWriter{}) | ||
} |
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 think it would be better to initialize levelRegex
in SetLogOutput
function instead of init
func (w *LogWriter) Write(p []byte) (n int, err error) { | ||
level := w.detectLogLevel(p) | ||
|
||
if level == LevelError || level == LevelWarning || level == LevelFatal || level == LevelPanic { |
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 profit of "Level*" variables since there is no way to customize logic of Writer
what do you think of this implementation?
levelRegex, err = regexp.Compile("level=(panic|fatal|warning|error)")
// ...
if levelRegex.Match(p) {
return os.Stderr.Write(p)
}
return os.Stderr.Write(p)
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.
Makes sense 🙂
I will perform some performance testing on this PR to analyze the impact. |
this pr look good to me, |
@iam-veeramalla could you please update on this? |
Hi @pasha-codefresh , We need to move out of the existing logging package as it is in maintianence mode. This PR does not solve the problem completely. We need to identify the package that we want to move to and re-work on this PR. |
can we close this pr for now and reopen new one with improved solution, so we will not have stale PR? @iam-veeramalla |
closing this PR, will open a new one with more details. |
@iam-veeramalla |
Signed-off-by: iam-veeramalla [email protected]
This PR fixes #3491. Send high level logs to Stderr and logs of normal execution to Stdout.
This PR sends Info, Debug, Warn and Trace logs to stdout. Error, Panic and Fatal are sent to stderr.
Checklist: