Hid requests for output.css and favicon from logging

This commit is contained in:
2025-02-09 17:46:35 +11:00
parent 49d9806bd6
commit 378840fe24

View File

@@ -2,6 +2,7 @@ package middleware
import ( import (
"net/http" "net/http"
"strings"
"time" "time"
"github.com/rs/zerolog" "github.com/rs/zerolog"
@@ -28,10 +29,13 @@ func Logging(logger *zerolog.Logger, next http.Handler) http.Handler {
statusCode: http.StatusOK, statusCode: http.StatusOK,
} }
next.ServeHTTP(wrapped, r) next.ServeHTTP(wrapped, r)
if !strings.Contains(r.URL.Path, "favicon.ico") &&
!strings.Contains(r.URL.Path, "output.css") {
logger.Info(). logger.Info().
Int("status", wrapped.statusCode). Int("status", wrapped.statusCode).
Str("method", r.Method). Str("method", r.Method).
Str("resource", r.URL.Path). Str("resource", r.URL.Path).
Dur("time_elapsed", time.Since(start)).Msg("Served") Dur("time_elapsed", time.Since(start)).Msg("Served")
}
}) })
} }