fix: 操作日志记录信息json序列化字符串

This commit is contained in:
TsMask
2025-08-12 10:37:24 +08:00
parent fa8da36b90
commit e3008c8de5

View File

@@ -2,7 +2,6 @@ package middleware
import ( import (
"encoding/json" "encoding/json"
"fmt"
"reflect" "reflect"
"strings" "strings"
"time" "time"
@@ -134,8 +133,15 @@ func OperateLog(options Options) gin.HandlerFunc {
contentDisposition := c.Writer.Header().Get("Content-Disposition") contentDisposition := c.Writer.Header().Get("Content-Disposition")
contentType := c.Writer.Header().Get("Content-Type") contentType := c.Writer.Header().Get("Content-Type")
content := contentType + contentDisposition content := contentType + contentDisposition
msg := fmt.Sprintf(`{"status":"%d","size":%d,"content-type":"%s"}`, status, c.Writer.Size(), content) msgByte, err := json.Marshal(map[string]any{
operaLog.OperaMsg = msg "status": status,
"size": c.Writer.Size(),
"content-type": content,
})
if err != nil {
operaLog.OperaMsg = ""
}
operaLog.OperaMsg = string(msgByte)
} }
// 日志记录时间 // 日志记录时间