Skip to content
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

Merged
merged 3 commits into from
Aug 15, 2018
Merged

Add debug check to logp.Logger #7965

merged 3 commits into from
Aug 15, 2018

Conversation

vjsamuel
Copy link
Contributor

@vjsamuel vjsamuel commented Aug 14, 2018

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.

@elasticmachine
Copy link
Collaborator

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?

@@ -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
Copy link
Member

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.

Copy link
Contributor Author

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

@andrewkroh
Copy link
Member

jenkins test this

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks

@ruflin
Copy link
Member

ruflin commented Aug 15, 2018

jenkins, test this

@ruflin
Copy link
Member

ruflin commented Aug 15, 2018

jenkins, test this

@ruflin ruflin merged commit 5b54084 into elastic:master Aug 15, 2018
@andrewkroh andrewkroh added the needs_backport PR is waiting to be backported to other branches. label Dec 18, 2018
andrewkroh pushed a commit to andrewkroh/beats that referenced this pull request Dec 18, 2018
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)
@andrewkroh andrewkroh added v6.6.0 and removed needs_backport PR is waiting to be backported to other branches. labels Dec 18, 2018
andrewkroh added a commit that referenced this pull request Dec 18, 2018
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants