mod: log middleware

This commit is contained in:
Nite07 2024-11-14 19:22:52 +08:00
parent d500ca7576
commit ced893ce76
2 changed files with 7 additions and 1 deletions

View File

@ -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 {

View File

@ -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),