From 18dcfd6a90b428bb71a7b55991580916d6ea148d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 12 Feb 2023 16:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=20gorm=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wrapper/gorm_v2.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wrapper/gorm_v2.go b/wrapper/gorm_v2.go index 75d781c..25f5968 100644 --- a/wrapper/gorm_v2.go +++ b/wrapper/gorm_v2.go @@ -56,7 +56,8 @@ func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.En // // Date : 3:36 PM 2021/12/24 func NewGormLoggerWithInstance(ctx *gin.Context, dbClient *gorm.DB, instance *zap.Logger, node string, extraCtxFieldList []string) logger.Interface { - return &Gorm{ + nodeArr := strings.Split(node, "|") + i := &Gorm{ dbClient: dbClient, instance: instance, traceIDField: "", @@ -65,6 +66,10 @@ func NewGormLoggerWithInstance(ctx *gin.Context, dbClient *gorm.DB, instance *za node: node, ctx: ctx, } + if len(nodeArr) >= 2 { + i.node = nodeArr[1] + i.flag = nodeArr[0] + } } // Gorm v2 版本库日志实现