From d8c81bbc6e698f11ac0e4c130cedb2dd3af5ae87 Mon Sep 17 00:00:00 2001 From: Bradley Jones Date: Tue, 9 May 2023 20:46:11 +0100 Subject: [PATCH] fix: ensure warn logs are formatted correctly Signed-off-by: Bradley Jones --- internal/logger/logger.go | 6 ++++++ pkg/inventory/ecs.go | 2 +- pkg/logger/logger.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index ecaec8a..d613c69 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -19,6 +19,8 @@ func (log NoOpLogger) Info(string, ...interface{}) {} func (log NoOpLogger) Warn(string, ...interface{}) {} +func (log NoOpLogger) Warnf(string, ...interface{}) {} + func (log NoOpLogger) Error(string, error, ...interface{}) {} type ZapLogger struct { @@ -41,6 +43,10 @@ func (log ZapLogger) Warn(msg string, args ...interface{}) { log.zap.Warnw(msg, args...) } +func (log ZapLogger) Warnf(msg string, args ...interface{}) { + log.zap.Warnf(msg, args...) +} + func (log ZapLogger) Error(msg string, err error, args ...interface{}) { args = append(args, "err", err) diff --git a/pkg/inventory/ecs.go b/pkg/inventory/ecs.go index 45ee2fe..9e389ea 100644 --- a/pkg/inventory/ecs.go +++ b/pkg/inventory/ecs.go @@ -86,7 +86,7 @@ func fetchContainersFromTasks(client ecsiface.ECSAPI, cluster string, tasks []*s if container.ImageDigest != nil { digest = *container.ImageDigest } else { - logger.Log.Warn("No image digest found for container: %s", *container.ContainerArn) + logger.Log.Warnf("No image digest found for container: %s", *container.ContainerArn) logger.Log.Warn("Ensure all ECS container hosts are running at least ECS Agent 1.70.0, which fixed a bug where image digests were not returned in the DescribeTasks API response.") } containers = append(containers, reporter.Container{ diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 766e2b8..24b45ba 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -3,6 +3,7 @@ package logger type Logger interface { Error(msg string, err error, args ...interface{}) Warn(msg string, args ...interface{}) + Warnf(msg string, args ...interface{}) Info(msg string, args ...interface{}) Debug(msg string, args ...interface{}) Debugf(msg string, args ...interface{})