upgrade: 升级日志数据构建
This commit is contained in:
14
util.go
14
util.go
@ -9,6 +9,7 @@ package logger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
@ -20,11 +21,18 @@ import (
|
||||
|
||||
func getStrVal(ctx context.Context, key string) string {
|
||||
val := ctx.Value(key)
|
||||
if nil == val {
|
||||
return ""
|
||||
}
|
||||
if nil != val {
|
||||
return wrapper.AnyDataType(val).ToString().Value()
|
||||
}
|
||||
if v := ctx.Value(consts.GinContextDataField); nil != v {
|
||||
if data, ok := v.(map[string]any); ok {
|
||||
if searchVal, exist := data[key]; exist && nil != searchVal {
|
||||
return fmt.Sprintf("%v", searchVal)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// NewLogData ...
|
||||
//
|
||||
|
Reference in New Issue
Block a user