Ver código fonte

gin请求日志添加时间单位
去除客户端ip日志项

jys 6 meses atrás
pai
commit
4db11ae817
1 arquivos alterados com 3 adições e 3 exclusões
  1. 3 3
      gin_logger.go

+ 3 - 3
gin_logger.go

@@ -4,6 +4,7 @@ import (
 	"github.com/gin-gonic/gin"
 	"runtime/debug"
 	"slices"
+	"strconv"
 	"time"
 )
 
@@ -18,10 +19,9 @@ func GinLogger(skipPaths []string) gin.HandlerFunc {
 		}
 
 		end := time.Now()
-		Info(" %d | %d | %s | %s		 \"%s\"",
+		Info(" %d | %s | %s		 \"%s\"",
 			c.Writer.Status(),
-			end.Sub(start),
-			c.ClientIP(),
+			strconv.Itoa(int(end.Sub(start).Milliseconds()))+"ms",
 			c.Request.Method,
 			path,
 		)