diff options
| author | William Hergès <william@herges.fr> | 2026-01-02 21:40:31 +0100 |
|---|---|---|
| committer | William Hergès <william@herges.fr> | 2026-01-02 21:40:31 +0100 |
| commit | bda7087704a949371f8e7e2c3deb63b5850349a6 (patch) | |
| tree | 7a163d86a55543df7a64c5554217395f32e7d612 /backend/admin.go | |
| parent | 9eb385780cd04238225113415810573bc1b67582 (diff) | |
feat(log): move in its own package
Diffstat (limited to 'backend/admin.go')
| -rw-r--r-- | backend/admin.go | 5 |
1 files changed, 3 insertions, 2 deletions
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 } |
