Skip to content

Commit

Permalink
fix: ensure warn logs are formatted correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Bradley Jones <[email protected]>
  • Loading branch information
bradleyjones committed May 9, 2023
1 parent 6221509 commit d8c81bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pkg/inventory/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down

0 comments on commit d8c81bb

Please sign in to comment.