From 4c5a5ad0f12b4320aae447322664d5f6d1e48fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 26 Aug 2023 13:21:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsql=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=97=A0trace=5Fid=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wrapper/gorm_v2.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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