From 64e3b5e0a66e5f30429e35733467668a33c83810 Mon Sep 17 00:00:00 2001 From: Stephen Levine Date: Thu, 5 Dec 2024 15:05:30 -0500 Subject: [PATCH 1/3] adjust logger --- lib/autoupdate/agent/logger.go | 6 ++++-- lib/autoupdate/agent/logger_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/autoupdate/agent/logger.go b/lib/autoupdate/agent/logger.go index 41333d96729cd..7249fc43489ae 100644 --- a/lib/autoupdate/agent/logger.go +++ b/lib/autoupdate/agent/logger.go @@ -46,8 +46,10 @@ type progressLogger struct { func (w *progressLogger) Write(p []byte) (n int, err error) { w.n += len(p) if w.n >= w.max*(w.l+1)/w.lines { - msg := fmt.Sprintf("%s - progress: %d%%", w.name, w.n*100/w.max) - w.log.Log(w.ctx, w.level, msg) //nolint:sloglint // msg cannot be constant + w.log.Log(w.ctx, w.level, "Download progress", + "name", w.name, + "progress", fmt.Sprintf("%d%%", w.n*100/w.max), + ) w.l++ } return len(p), nil diff --git a/lib/autoupdate/agent/logger_test.go b/lib/autoupdate/agent/logger_test.go index 9eec9348c7b60..41c9ddf097e37 100644 --- a/lib/autoupdate/agent/logger_test.go +++ b/lib/autoupdate/agent/logger_test.go @@ -177,7 +177,7 @@ func TestProgressLogger(t *testing.T) { v, err := io.ReadAll(out) require.NoError(t, err) if len(v) > 0 { - e.out = fmt.Sprintf(`msg="test - progress: %s"`+"\n", e.out) + e.out = fmt.Sprintf(`msg="Download progress" name=test progress=%s`+"\n", e.out) } require.Equal(t, e.out, string(v)) } From b1ba5b66ce97f08045c68cba1fe8530dd9043c86 Mon Sep 17 00:00:00 2001 From: Stephen Levine Date: Thu, 5 Dec 2024 15:10:38 -0500 Subject: [PATCH 2/3] fix --- lib/autoupdate/agent/logger.go | 2 +- lib/autoupdate/agent/logger_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/autoupdate/agent/logger.go b/lib/autoupdate/agent/logger.go index 7249fc43489ae..5c8ad4d774eae 100644 --- a/lib/autoupdate/agent/logger.go +++ b/lib/autoupdate/agent/logger.go @@ -46,7 +46,7 @@ type progressLogger struct { func (w *progressLogger) Write(p []byte) (n int, err error) { w.n += len(p) if w.n >= w.max*(w.l+1)/w.lines { - w.log.Log(w.ctx, w.level, "Download progress", + w.log.Log(w.ctx, w.level, "Downloading", "name", w.name, "progress", fmt.Sprintf("%d%%", w.n*100/w.max), ) diff --git a/lib/autoupdate/agent/logger_test.go b/lib/autoupdate/agent/logger_test.go index 41c9ddf097e37..a8166db7d5c42 100644 --- a/lib/autoupdate/agent/logger_test.go +++ b/lib/autoupdate/agent/logger_test.go @@ -177,7 +177,7 @@ func TestProgressLogger(t *testing.T) { v, err := io.ReadAll(out) require.NoError(t, err) if len(v) > 0 { - e.out = fmt.Sprintf(`msg="Download progress" name=test progress=%s`+"\n", e.out) + e.out = fmt.Sprintf(`msg=Downloading name=test progress=%s`+"\n", e.out) } require.Equal(t, e.out, string(v)) } From 0b46c738e19202ec912989fa83bf7fe8a5718196 Mon Sep 17 00:00:00 2001 From: Stephen Levine Date: Thu, 5 Dec 2024 15:14:00 -0500 Subject: [PATCH 3/3] fix --- lib/autoupdate/agent/logger.go | 2 +- lib/autoupdate/agent/logger_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/autoupdate/agent/logger.go b/lib/autoupdate/agent/logger.go index 5c8ad4d774eae..bd50ee50859a4 100644 --- a/lib/autoupdate/agent/logger.go +++ b/lib/autoupdate/agent/logger.go @@ -47,7 +47,7 @@ func (w *progressLogger) Write(p []byte) (n int, err error) { w.n += len(p) if w.n >= w.max*(w.l+1)/w.lines { w.log.Log(w.ctx, w.level, "Downloading", - "name", w.name, + "file", w.name, "progress", fmt.Sprintf("%d%%", w.n*100/w.max), ) w.l++ diff --git a/lib/autoupdate/agent/logger_test.go b/lib/autoupdate/agent/logger_test.go index a8166db7d5c42..2a8430ef8cf44 100644 --- a/lib/autoupdate/agent/logger_test.go +++ b/lib/autoupdate/agent/logger_test.go @@ -177,7 +177,7 @@ func TestProgressLogger(t *testing.T) { v, err := io.ReadAll(out) require.NoError(t, err) if len(v) > 0 { - e.out = fmt.Sprintf(`msg=Downloading name=test progress=%s`+"\n", e.out) + e.out = fmt.Sprintf(`msg=Downloading file=test progress=%s`+"\n", e.out) } require.Equal(t, e.out, string(v)) }