package fslog import ( "bytes" ginzap "github.com/gin-contrib/zap" "github.com/gin-gonic/gin" "go.uber.org/zap" "go.uber.org/zap/zapcore" "io" "time" ) func GinLogger() gin.HandlerFunc { lazyInitialize() return ginzap.GinzapWithConfig(logger, &ginzap.Config{ UTC: true, TimeFormat: time.RFC3339, Context: func(c *gin.Context) []zapcore.Field { var body []byte var buf bytes.Buffer body, err := io.ReadAll(c.Request.Body) if err != nil { return make([]zapcore.Field, 0) } c.Request.Body = io.NopCloser(&buf) return []zapcore.Field{zap.String("body", string(body))} }, }) } func GinRecovery() gin.HandlerFunc { lazyInitialize() return ginzap.RecoveryWithZap(logger, true) }