all: imp code

This commit is contained in:
Stanislav Chzhen 2024-09-05 18:07:06 +03:00
parent 022c90496a
commit 45b2fc6a05
2 changed files with 7 additions and 5 deletions

View file

@ -57,11 +57,13 @@ func ErrorAndLog(
l.ErrorContext(
ctx,
"http error",
"method", r.Method,
"host", r.Host,
"url", r.URL,
"method", r.Method,
"raddr", r.RemoteAddr,
"request_uri", r.RequestURI,
slogutil.KeyError, text,
)
http.Error(w, text, code)
}

View file

@ -466,13 +466,13 @@ func (s *StatsCtx) flushDB(id, limit uint32, ptr *unit) (cont bool, sleepFor tim
if delErr != nil {
// TODO(e.burkov): Improve the algorithm of deleting the oldest bucket
// to avoid the error.
logFunc := s.logger.Warn
lvl := slog.LevelWarn
if !errors.Is(delErr, bbolt.ErrBucketNotFound) {
isCommitable = false
logFunc = s.logger.Error
lvl = slog.LevelError
}
logFunc("deleting bucket", slogutil.KeyError, delErr)
s.logger.Log(context.TODO(), lvl, "deleting bucket", slogutil.KeyError, delErr)
}
return true, 0