Skip to content

Commit

Permalink
modules: Adjust the log throttle logic a little
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Oct 28, 2023
1 parent 6690409 commit 3f64b5a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/client.go
Expand Up @@ -106,16 +106,18 @@ func NewClient(cfg ClientConfig) *Client {

var throttleSince time.Time
throttle := func(f func()) {
// Skip the first call.
// This is used for "download" etc. and we want to avoid
// logging anything if it is fast.
if throttleSince.IsZero() {
throttleSince = time.Now()
f()
return
}
if time.Since(throttleSince) < 6*time.Second {
return
}
throttleSince = time.Now()
f()
throttleSince = time.Now()
}

return &Client{
Expand Down

0 comments on commit 3f64b5a

Please sign in to comment.