From 9f4e7ee4bd3f5ef77b111f6fc233eefbd3060d8b Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Mon, 14 Nov 2022 11:16:01 +0530 Subject: [PATCH] Check for ignored with fully formatted log message (#1163) --- pkg/logger/logadapter.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/logger/logadapter.go b/pkg/logger/logadapter.go index 62830926a..7475eff93 100644 --- a/pkg/logger/logadapter.go +++ b/pkg/logger/logadapter.go @@ -51,10 +51,11 @@ func (l *logAdapter) Infof(format string, args ...interface{}) { if l.level > zapcore.InfoLevel { return } - if l.shouldIgnore(format) { + msg := fmt.Sprintf(format, args...) + if l.shouldIgnore(msg) { return } - l.logger.Info(fmt.Sprintf(format, args...)) + l.logger.Info(msg) } func (l *logAdapter) Warn(msg string) { @@ -71,10 +72,11 @@ func (l *logAdapter) Warnf(format string, args ...interface{}) { if l.level > zapcore.WarnLevel { return } - if l.shouldIgnore(format) { + msg := fmt.Sprintf(format, args...) + if l.shouldIgnore(msg) { return } - l.logger.V(-1).Info(fmt.Sprintf(format, args...)) + l.logger.V(-1).Info(msg) } func (l *logAdapter) Error(msg string) { @@ -91,10 +93,11 @@ func (l *logAdapter) Errorf(format string, args ...interface{}) { if l.level > zapcore.ErrorLevel { return } - if l.shouldIgnore(format) { + msg := fmt.Sprintf(format, args...) + if l.shouldIgnore(msg) { return } - l.logger.Error(nil, fmt.Sprintf(format, args...)) + l.logger.Error(nil, msg) } func (l *logAdapter) shouldIgnore(msg string) bool {