From bda7087704a949371f8e7e2c3deb63b5850349a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Herg=C3=A8s?= Date: Fri, 2 Jan 2026 21:40:31 +0100 Subject: feat(log): move in its own package --- backend/admin.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'backend/admin.go') diff --git a/backend/admin.go b/backend/admin.go index 6fc61eb..89cc849 100644 --- a/backend/admin.go +++ b/backend/admin.go @@ -8,6 +8,7 @@ import ( "sync" "time" + "git.anhgelus.world/anhgelus/small-web/backend/log" "git.anhgelus.world/anhgelus/small-web/backend/storage" "github.com/go-chi/chi/v5" ) @@ -68,7 +69,7 @@ func rateLimit(ctx context.Context) bool { return false } v.since = time.Now() - GetLogger(ctx).Warn("rate limiting IP", "ip", ip, "duration", rateLimitDuration(v.n).String()) + log.GetLogger(ctx).Warn("rate limiting IP", "ip", ip, "duration", rateLimitDuration(v.n).String()) go func(v *to, ip string) { time.Sleep(3 * time.Hour) v.n = max(v.n-4, 0) @@ -106,7 +107,7 @@ func HandleAdmin(r *chi.Mux) { if rawPage != "" { page, err = strconv.Atoi(rawPage) if err != nil || page < 1 { - GetLogger(ctx).Warn("invalid page number", "requested", rawPage) + log.GetLogger(ctx).Warn("invalid page number", "requested", rawPage) http.Error(w, "Bad request", http.StatusBadRequest) return } -- cgit v1.2.3