From 45b2fc6a05a4f7775d2b6fa056c81d53d4f402d7 Mon Sep 17 00:00:00 2001 From: Stanislav Chzhen Date: Thu, 5 Sep 2024 18:07:06 +0300 Subject: [PATCH] all: imp code --- internal/aghhttp/aghhttp.go | 6 ++++-- internal/stats/stats.go | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/aghhttp/aghhttp.go b/internal/aghhttp/aghhttp.go index 94d3588d..48694a8e 100644 --- a/internal/aghhttp/aghhttp.go +++ b/internal/aghhttp/aghhttp.go @@ -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) } diff --git a/internal/stats/stats.go b/internal/stats/stats.go index b77c2aaf..c6de4c66 100644 --- a/internal/stats/stats.go +++ b/internal/stats/stats.go @@ -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