mod: log middleware
This commit is contained in:
parent
d500ca7576
commit
ced893ce76
@ -26,7 +26,7 @@ type config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type webhooks 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 {
|
type server struct {
|
||||||
|
@ -3,6 +3,7 @@ package middleware
|
|||||||
import (
|
import (
|
||||||
"pcgamedb/log"
|
"pcgamedb/log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -22,6 +23,11 @@ func Logger() gin.HandlerFunc {
|
|||||||
statusCode := c.Writer.Status()
|
statusCode := c.Writer.Status()
|
||||||
clientIP := c.ClientIP()
|
clientIP := c.ClientIP()
|
||||||
|
|
||||||
|
if strings.HasPrefix(reqURI, "/swagger/") ||
|
||||||
|
strings.EqualFold(reqURI, "/favicon.ico") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log.Logger.Info(
|
log.Logger.Info(
|
||||||
"request",
|
"request",
|
||||||
zap.Int("code", statusCode),
|
zap.Int("code", statusCode),
|
||||||
|
Loading…
Reference in New Issue
Block a user