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