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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff]
internal monitoring data. {issue}7807[7807]
- Allow for cloud-id to specify a custom port. This makes cloud-id work in ECE contexts. {pull}7887[7887]
- Add support to grow or shrink an existing spool file between restarts. {pull}7859[7859]
- Add debug check to logp.Logger {pull}7965[7965]

*Auditbeat*

Expand Down
6 changes: 6 additions & 0 deletions libbeat/logp/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package logp

import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

// LogOption configures a Logger.
Expand Down Expand Up @@ -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

}

// Sprintf

// Debugf uses fmt.Sprintf to construct and log a message.
Expand Down