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