-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add debug check to logp.Logger #7965
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
libbeat/logp/logger.go
Outdated
@@ -96,6 +97,11 @@ func (l *Logger) DPanic(args ...interface{}) { | |||
l.sugar.DPanic(args...) | |||
} | |||
|
|||
// IsDebug checks to see if the given logger is Debug enabled. | |||
func (l *Logger) IsDebug() bool { | |||
return l.sugar.Desugar().Check(zapcore.DebugLevel, "") != 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.
We should probably store the original zap.Logger inside of logp.Logger
. Originally it held both, but I dropped it because it was never used.
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.
@andrewkroh, i have made the necessary change
jenkins test this |
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. Thanks
jenkins, test this |
jenkins, test this |
This PR adds a debug check I made sure to check if `Desugar()` is expensive or not. The API is documented as follows: ``` // Desugar unwraps a SugaredLogger, exposing the original Logger. Desugaring // is quite inexpensive, so it's reasonable for a single application to use // both Loggers and SugaredLoggers, converting between them on the boundaries // of performance-sensitive code. ``` (cherry picked from commit 5b54084)
This PR adds a debug check I made sure to check if `Desugar()` is expensive or not. The API is documented as follows: ``` // Desugar unwraps a SugaredLogger, exposing the original Logger. Desugaring // is quite inexpensive, so it's reasonable for a single application to use // both Loggers and SugaredLoggers, converting between them on the boundaries // of performance-sensitive code. ``` (cherry picked from commit 5b54084)
This PR adds a debug check
I made sure to check if
Desugar()
is expensive or not. The API is documented as follows: