diff --git a/wrapper/gorm_v2.go b/wrapper/gorm_v2.go index 34e8951..330935f 100644 --- a/wrapper/gorm_v2.go +++ b/wrapper/gorm_v2.go @@ -199,7 +199,10 @@ func (g *Gorm) write(dataList []zap.Field, level string) { // // Date : 10:11 下午 2021/3/1 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