Skip to content

Commit

Permalink
Merge pull request #811 from wangle201210/fix/logger
Browse files Browse the repository at this point in the history
fix🐛: reset default logger fields
  • Loading branch information
wenjianzhang authored Aug 29, 2024
2 parents 93f25c6 + dd905a2 commit c0c1603
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ func LoggerToFile() gin.HandlerFunc {
"uri": reqUri,
}
log.WithFields(logData).Info()

defer func() {
log.Fields(map[string]interface{}{})
}()
if c.Request.Method != "OPTIONS" && config.LoggerConfig.EnabledDB && statusCode != 404 {
SetDBOperLog(c, clientIP, statusCode, reqUri, reqMethod, latencyTime, body, result, statusBus)
}
Expand Down Expand Up @@ -126,7 +128,7 @@ func SetDBOperLog(c *gin.Context, clientIP string, statusCode int, reqUri string
message, err := sdk.Runtime.GetStreamMessage("", global.OperateLog, l)
if err != nil {
log.Errorf("GetStreamMessage error, %s", err.Error())
//日志报错错误,不中断请求
// 日志报错错误,不中断请求
} else {
err = q.Append(message)
if err != nil {
Expand Down

0 comments on commit c0c1603

Please sign in to comment.