diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 16373fddd81..e6c0ebf3f1b 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -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* diff --git a/libbeat/logp/logger.go b/libbeat/logp/logger.go index 19bcb252bec..278aabb42cf 100644 --- a/libbeat/logp/logger.go +++ b/libbeat/logp/logger.go @@ -19,6 +19,7 @@ package logp import ( "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) // LogOption configures a Logger. @@ -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 +} + // Sprintf // Debugf uses fmt.Sprintf to construct and log a message.