Skip to content

Commit

Permalink
stats: imp logging again
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Aug 22, 2022
1 parent 34fc666 commit d14a5ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ and this project adheres to

### Fixed

- Excessive logging of a non-critical statistics error ([#4850]).
- Unnecessary logging of a non-critical statistics errors ([#4850]).

[#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993
[#4850]: https://github.com/AdguardTeam/AdGuardHome/issues/4850
Expand Down
9 changes: 4 additions & 5 deletions internal/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (s *StatsCtx) flush() (cont bool, sleepFor time.Duration) {
}
defer func() {
if err = finishTxn(tx, isCommitable); err != nil {
log.Error("stats: warning: %s", err)
log.Error("stats: %s", err)
}
}()

Expand All @@ -408,15 +408,14 @@ func (s *StatsCtx) flush() (cont bool, sleepFor time.Duration) {

delErr := tx.DeleteBucket(idToUnitName(id - limit))
if delErr != nil {
logFunc := log.Error
// TODO(e.burkov): Improve the algorithm of deleting the oldest bucket
// to avoid the error.
if !errors.Is(delErr, bbolt.ErrBucketNotFound) {
isCommitable = false
logFunc = log.Debug
log.Debug("stats: warning: deleting unit: %s", delErr)
} else {
log.Error("stats: deleting unit: %s", delErr)
}

logFunc("stats: warning: deleting unit: %s", delErr)
}

return true, 0
Expand Down

0 comments on commit d14a5ca

Please sign in to comment.