From 9b861374e3efa1c443be889864c7b4acc1abb329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=B7=E6=BB=A1?= Date: Fri, 5 Mar 2021 00:02:58 +0800 Subject: [PATCH] =?UTF-8?q?gorm=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84trace=5Fid=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logger/wrapper/gorm_v2.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/logger/wrapper/gorm_v2.go b/logger/wrapper/gorm_v2.go index dcdd1b5..f749210 100644 --- a/logger/wrapper/gorm_v2.go +++ b/logger/wrapper/gorm_v2.go @@ -32,6 +32,9 @@ func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.En if nil != err { return nil, err } + if len(traceIDField) == 0 { + traceIDField = "trace_id" + } return &Gorm{ instance: logInstance, }, nil