log : Log middleware modification

This commit is contained in:
zhangwenjian committed 2020-07-27 22:40:12 +08:00
1 parent f3104a2d28
commit be19638a59
1 file changed
+11 -10
+11 -10
View File
@@ -1,6 +1,7 @@
package middleware package middleware
import ( import (
"fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"go-admin/global" "go-admin/global"
"go-admin/models" "go-admin/models"
@@ -39,18 +40,18 @@ func LoggerToFile() gin.HandlerFunc {
clientIP := c.ClientIP() clientIP := c.ClientIP()
// 日志格式 // 日志格式
//global.AccessLogger.Printf(" %s %3d %13v %15s %s %s \r\n", fmt.Printf("%s [INFO] %s %s %3d %13v %15s \r\n",
// startTime.Format("2006-01-02 15:04:05.9999"), startTime.Format("2006-01-02 15:04:05.9999"),
// statusCode, reqMethod,
// latencyTime, reqUri,
// clientIP, statusCode,
// reqMethod, latencyTime,
// reqUri, clientIP,
//) )
global.AccessLogger.Info(statusCode, latencyTime, clientIP, reqMethod, reqUri) global.RequestLogger.Info(statusCode, latencyTime, clientIP, reqMethod, reqUri)
if c.Request.Method != "GET" && c.Request.Method != "OPTIONS" && config2.LoggerConfig.Enabled { if c.Request.Method != "GET" && c.Request.Method != "OPTIONS" && config2.LoggerConfig.EnabledDB {
SetDBOperLog(c, clientIP, statusCode, reqUri, reqMethod, latencyTime) SetDBOperLog(c, clientIP, statusCode, reqUri, reqMethod, latencyTime)
} }
} }