From 043f82ad794eb64a5550d8b80703114a055701d9 Mon Sep 17 00:00:00 2001 From: ElevenNotes Date: Fri, 27 Jun 2025 22:24:22 +0200 Subject: [PATCH] fix: less noisy logging for certain GET requests (#681) Co-authored-by: Kyle Mendell Co-authored-by: Elias Schneider --- .../internal/bootstrap/router_bootstrap.go | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go index acf27d2e..76693709 100644 --- a/backend/internal/bootstrap/router_bootstrap.go +++ b/backend/internal/bootstrap/router_bootstrap.go @@ -9,6 +9,7 @@ import ( "net/http" "os" "strconv" + "strings" "time" "github.com/pocket-id/pocket-id/backend/frontend" @@ -47,7 +48,26 @@ func initRouterInternal(db *gorm.DB, svc *services) (utils.Service, error) { gin.SetMode(gin.TestMode) } - r := gin.Default() + // do not log these URLs + loggerSkipPathsPrefix := []string{ + "GET /application-configuration/logo", + "GET /application-configuration/background-image", + "GET /application-configuration/favicon", + "GET /_app", + "GET /fonts", + "GET /healthz", + "HEAD /healthz", + } + + r := gin.New() + r.Use(gin.LoggerWithConfig(gin.LoggerConfig{Skip: func(c *gin.Context) bool { + for _, prefix := range loggerSkipPathsPrefix { + if strings.HasPrefix(c.Request.Method+" "+c.Request.URL.String(), prefix) { + return true + } + } + return false + }})) if !common.EnvConfig.TrustProxy { _ = r.SetTrustedProxies(nil)