-
Notifications
You must be signed in to change notification settings - Fork 301
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: can't show debug level logging message #1808
Conversation
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #1808 +/- ##
==========================================
+ Coverage 65.05% 65.24% +0.19%
==========================================
Files 86 86
Lines 12281 12316 +35
==========================================
+ Hits 7989 8036 +47
+ Misses 3777 3769 -8
+ Partials 515 511 -4
|
ptal @qicz |
@@ -55,7 +55,7 @@ func (l Logger) WithName(name string) Logger { | |||
return Logger{ | |||
Logger: zapr.NewLogger(logger).WithName(name), | |||
logging: l.logging, | |||
sugaredLogger: l.sugaredLogger, | |||
sugaredLogger: logger.Sugar(), |
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.
inited
gateway/internal/logging/log.go
Lines 25 to 44 in 4285f4e
func NewLogger(logging *v1alpha1.EnvoyGatewayLogging) Logger { | |
logger := initZapLogger(logging, logging.Level[v1alpha1.LogComponentGatewayDefault]) | |
return Logger{ | |
Logger: zapr.NewLogger(logger), | |
logging: logging, | |
sugaredLogger: logger.Sugar(), | |
} | |
} | |
func DefaultLogger(level v1alpha1.LogLevel) Logger { | |
logging := v1alpha1.DefaultEnvoyGatewayLogging() | |
logger := initZapLogger(logging, level) | |
return Logger{ | |
Logger: zapr.NewLogger(logger), | |
logging: logging, | |
sugaredLogger: logger.Sugar(), | |
} | |
} |
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.
@qicz The issue with the current implementation sugaredLogger: l.sugaredLogger
is that the logging level of the returned SugaredLogger is incorrect. Please see the test TestLoggerWithName
in this PR.
logger.Sugar().Debugf("debug message")
...
assert.Contains(t, capturedOutput, "debug message")
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.
misunderstand it, you are 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.
LGTM
What type of PR is this?
Fix: EG can't show debug level logging message because the sugar logger created in the WithName function is incorrect.