fix: persist logs without caller path
Deploy olons-admin production / deploy (push) Successful in 6m0s
Deploy olons-admin production / deploy (push) Successful in 6m0s
This commit is contained in:
@@ -111,7 +111,7 @@ func LoggingServeLogHandler(ctx context.Context, in *glog.HandlerInput) {
|
||||
data.LevelFormat = in.LevelFormat
|
||||
data.Content = in.Content
|
||||
data.Stack = gjson.New(charset.ParseStack(in.Stack))
|
||||
data.Line = strings.TrimRight(in.CallerPath, ":")
|
||||
data.Line = normalizeServeLogLine(in.CallerPath)
|
||||
data.TriggerNs = in.Time.UnixNano()
|
||||
data.Status = consts.StatusEnabled
|
||||
|
||||
@@ -135,6 +135,14 @@ func LoggingServeLogHandler(ctx context.Context, in *glog.HandlerInput) {
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeServeLogLine(callerPath string) string {
|
||||
line := strings.TrimRight(callerPath, ":")
|
||||
if line == "" {
|
||||
return "unknown"
|
||||
}
|
||||
return line
|
||||
}
|
||||
|
||||
// InitTrace 初始化链路追踪
|
||||
func InitTrace(ctx context.Context) {
|
||||
if !g.Cfg().MustGet(ctx, "jaeger.switch").Bool() {
|
||||
|
||||
Reference in New Issue
Block a user