From 378840fe2477abca211e3326652de9acb8b4c4a3 Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Sun, 9 Feb 2025 17:46:35 +1100 Subject: [PATCH] Hid requests for output.css and favicon from logging --- middleware/logging.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/middleware/logging.go b/middleware/logging.go index ef37c5c..3b8307c 100644 --- a/middleware/logging.go +++ b/middleware/logging.go @@ -2,6 +2,7 @@ package middleware import ( "net/http" + "strings" "time" "github.com/rs/zerolog" @@ -28,10 +29,13 @@ func Logging(logger *zerolog.Logger, next http.Handler) http.Handler { statusCode: http.StatusOK, } next.ServeHTTP(wrapped, r) - logger.Info(). - Int("status", wrapped.statusCode). - Str("method", r.Method). - Str("resource", r.URL.Path). - Dur("time_elapsed", time.Since(start)).Msg("Served") + if !strings.Contains(r.URL.Path, "favicon.ico") && + !strings.Contains(r.URL.Path, "output.css") { + logger.Info(). + Int("status", wrapped.statusCode). + Str("method", r.Method). + Str("resource", r.URL.Path). + Dur("time_elapsed", time.Since(start)).Msg("Served") + } }) }