|
@@ -18,19 +18,15 @@ func GinLogger() gin.HandlerFunc {
|
|
Context: func(c *gin.Context) []zapcore.Field {
|
|
Context: func(c *gin.Context) []zapcore.Field {
|
|
var body []byte
|
|
var body []byte
|
|
var buf bytes.Buffer
|
|
var buf bytes.Buffer
|
|
- fields := make([]zapcore.Field, 0)
|
|
|
|
|
|
|
|
body, err := io.ReadAll(c.Request.Body)
|
|
body, err := io.ReadAll(c.Request.Body)
|
|
if err != nil {
|
|
if err != nil {
|
|
return make([]zapcore.Field, 0)
|
|
return make([]zapcore.Field, 0)
|
|
}
|
|
}
|
|
|
|
|
|
- if body != nil && len(body) != 0 {
|
|
|
|
- fields = append(fields, zap.String("body", string(body)))
|
|
|
|
- c.Request.Body = io.NopCloser(&buf)
|
|
|
|
- }
|
|
|
|
|
|
+ c.Request.Body = io.NopCloser(&buf)
|
|
|
|
|
|
- return fields
|
|
|
|
|
|
+ return []zapcore.Field{zap.String("body", string(body))}
|
|
},
|
|
},
|
|
})
|
|
})
|
|
}
|
|
}
|