From d14a5cabecba75e9f0d401e61994d0efd2b324ff Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Mon, 22 Aug 2022 14:09:15 +0300 Subject: [PATCH] stats: imp logging again --- CHANGELOG.md | 2 +- internal/stats/stats.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cfd64739b..cfdad63b987 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/internal/stats/stats.go b/internal/stats/stats.go index 8c2bba766be..f4bbbea3c0b 100644 --- a/internal/stats/stats.go +++ b/internal/stats/stats.go @@ -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) } }() @@ -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