升级 gorm日志实现

This commit is contained in:
白茶清欢 2023-02-12 16:06:14 +08:00
parent 013e3feb3c
commit 18dcfd6a90
1 changed files with 6 additions and 1 deletions

View File

@ -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 版本库日志实现