日志参数转字符串

This commit is contained in:
yuguojian 2025-07-15 15:26:59 +08:00
parent 093b34f32f
commit 7f0c64fd8a
2 changed files with 4 additions and 83 deletions

View File

@ -1,75 +0,0 @@
{
"settings": {
"index": {
"mapping": {
"source": {
"mode": "synthetic"
}
}
}
},
"mappings": {
"properties": {
"caller": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"created_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||epoch_second"
},
"level": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"log": {
"properties": {
"at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||epoch_second"
},
"log_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"param": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"result": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}
}
}

View File

@ -36,8 +36,8 @@ const (
)
type Operator struct {
ID int // 系统ID设置0
OperatorType OperatorType
ID int // 系统ID设置0
OperatorType OperatorType `json:"operator_type"`
}
type LogInfo struct {
@ -91,7 +91,7 @@ func ZapFatal(logger *zap.Logger, log *LogInfo) {
func HandleLog(log *LogInfo) {
// 处理 Param
//log.Param = processValue(log.Param)
log.Param = processValue(log.Param)
// 处理 Result
log.Result = processValue(log.Result)
}
@ -150,9 +150,5 @@ func processValue(value interface{}) interface{} {
if value == nil {
return ""
}
if _, ok := value.(error); ok {
return fmt.Sprintf("%+v", value)
} else {
return value
}
return fmt.Sprintf("%+v", value)
}