From ced893ce7645452933d24c49f4b6fb6081f0a3a4 Mon Sep 17 00:00:00 2001 From: nite07 Date: Thu, 14 Nov 2024 19:22:52 +0800 Subject: [PATCH] mod: log middleware --- config/config.go | 2 +- server/middleware/log.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index e034f15..985777d 100644 --- a/config/config.go +++ b/config/config.go @@ -26,7 +26,7 @@ type config struct { } type webhooks struct { - CrawlTask []string `env:"WEBHOOKS_ERROR_TASK" json:"crawl_task"` + CrawlTask []string `env:"WEBHOOKS_CRAWL_TASK" json:"crawl_task"` } type server struct { diff --git a/server/middleware/log.go b/server/middleware/log.go index b1192ba..ea47dc7 100644 --- a/server/middleware/log.go +++ b/server/middleware/log.go @@ -3,6 +3,7 @@ package middleware import ( "pcgamedb/log" "strconv" + "strings" "time" "github.com/gin-gonic/gin" @@ -22,6 +23,11 @@ func Logger() gin.HandlerFunc { statusCode := c.Writer.Status() clientIP := c.ClientIP() + if strings.HasPrefix(reqURI, "/swagger/") || + strings.EqualFold(reqURI, "/favicon.ico") { + return + } + log.Logger.Info( "request", zap.Int("code", statusCode),