fix: 操作日志记录信息json序列化字符串
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
// 日志记录时间
|
||||
|
||||
Reference in New Issue
Block a user