Skip to content

Commit

Permalink
[teleport-update] Adjust download progress log output (#49845)
Browse files Browse the repository at this point in the history
* adjust logger

* fix

* fix
  • Loading branch information
sclevine authored Dec 5, 2024
1 parent a33473d commit 0131f45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/autoupdate/agent/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "Downloading",
"file", w.name,
"progress", fmt.Sprintf("%d%%", w.n*100/w.max),
)
w.l++
}
return len(p), nil
Expand Down
2 changes: 1 addition & 1 deletion lib/autoupdate/agent/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=Downloading file=test progress=%s`+"\n", e.out)
}
require.Equal(t, e.out, string(v))
}
Expand Down

0 comments on commit 0131f45

Please sign in to comment.