提交 f090300d authored 作者: mooncake9527's avatar mooncake9527

修改

上级 5e04fef8
......@@ -12,14 +12,11 @@ import (
)
const (
GinContextKey = "gin_context"
KeyConfigFile = "config_file"
KeyConfigCenter = "config_center"
GinContextKey = "ginContext"
HeaderXTimestampKey = "Timestamp"
KeyReqBody = "req-body"
KeyRspBody = "rsp-body"
KeyTid = "tid"
KeyClientIP = "client_ip"
KeyReqBody = "reqBody"
KeyRspBody = "rspBody"
KeyClientIP = "clientIP"
KeyUID = "userId"
KeyUType = "userType"
KeyCompanyID = "companyId"
......@@ -115,10 +112,10 @@ func GetCtxUserToken(c context.Context) string {
}
func GetGinCtxTid(c *gin.Context) string {
tid := c.GetString(KeyTid)
tid := c.GetString(ContextTraceIDKey)
if tid == "" {
tid = GenerateTid()
c.Set(KeyTid, tid)
c.Set(ContextTraceIDKey, tid)
}
return tid
}
......@@ -129,7 +126,7 @@ func GenerateTid() string {
func GetCtxTid(ctx context.Context) string {
tid := ""
tidVal := ctx.Value(KeyTid)
tidVal := ctx.Value(ContextTraceIDKey)
if tidVal != nil {
if str, ok := tidVal.(string); ok {
tid = str
......
......@@ -28,7 +28,7 @@ func NewCustomGormLogger(l *zap.Logger, requestIDKey string, logLevel logger.Log
l, _ = zap.NewProduction()
}
if requestIDKey == "" {
requestIDKey = "traceID"
requestIDKey = "X-Request-ID"
}
if logLevel == 0 {
logLevel = logger.Info
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论