修复sql日志无trace_id问题

This commit is contained in:
白茶清欢 2023-08-26 13:21:19 +08:00
parent 4566a456d9
commit 4c5a5ad0f1

View File

@ -199,7 +199,10 @@ func (g *Gorm) write(dataList []zap.Field, level string) {
// //
// Date : 10:11 下午 2021/3/1 // Date : 10:11 下午 2021/3/1
func (g *Gorm) getTraceID(ctx context.Context) string { func (g *Gorm) getTraceID(ctx context.Context) string {
return fmt.Sprintf("%v", ctx.Value(g.traceIDField)) if nil == g.ctx {
return ""
}
return g.ctx.GetString(g.traceIDField)
} }
// GetGormSQL 获取trace fn // GetGormSQL 获取trace fn