升级数据库日志

This commit is contained in:
2024-07-24 22:03:22 +08:00
parent 77de4c7fd9
commit 0bc05b3816
4 changed files with 35 additions and 27 deletions

10
util.go
View File

@ -10,10 +10,8 @@ package logger
import (
"os"
ginRequest "git.zhangdeman.cn/zhangdeman/gin/request"
"git.zhangdeman.cn/zhangdeman/network/util"
"git.zhangdeman.cn/zhangdeman/serialize"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
@ -22,13 +20,13 @@ import (
// Author : go_developer@163.com<白茶清欢>
//
// Date : 16:21 2024/7/23
func NewLogData(ctx *gin.Context, logType string, code string, logData map[string]any) *LogData {
func NewLogData(logType string, code string, logData map[string]any) *LogData {
if logData == nil {
logData = make(map[string]any)
}
hostname, _ := os.Hostname()
commonLogData := &LogData{
Uri: ginRequest.WrapperHandle.GetUri(ctx, ""),
Uri: "",
TraceID: "",
UserID: "",
UserRoleID: "",
@ -36,7 +34,7 @@ func NewLogData(ctx *gin.Context, logType string, code string, logData map[strin
LogType: logType,
CodeVersion: "",
ServiceVersion: "",
ClientIp: ginRequest.WrapperHandle.GetClientIp(ctx, "0.0.0.0"),
ClientIp: "",
ServerIp: util.IP.GetHostIP(),
Hostname: hostname,
Code: code,
@ -51,7 +49,7 @@ func NewLogData(ctx *gin.Context, logType string, code string, logData map[strin
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:33 2024/7/23
func ZapLogDataList(ctx *gin.Context, logData *LogData) []zap.Field {
func ZapLogDataList(logData *LogData) []zap.Field {
logDataList := make([]zap.Field, 0)
if logData == nil {
return logDataList