From cdf75b507bbfcdb7cff9f4fd619819c11b7b63e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=B7=E6=BB=A1?= Date: Sat, 6 Mar 2021 13:46:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=85=E8=A3=85=E6=97=A5=E5=BF=97=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BC=A0=E5=85=A5skip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logger/wrapper/gorm_v2.go | 4 ++-- logger/wrapper/http_gin.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/logger/wrapper/gorm_v2.go b/logger/wrapper/gorm_v2.go index cb94ed0..fc32617 100644 --- a/logger/wrapper/gorm_v2.go +++ b/logger/wrapper/gorm_v2.go @@ -27,8 +27,8 @@ import ( // Author : go_developer@163.com<张德满> // // Date : 9:56 下午 2021/3/1 -func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger2.RotateLogConfig, traceIDField string) (logger.Interface, error) { - logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCallerSkip(3), logger2.WithCaller()} +func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger2.RotateLogConfig, traceIDField string, skip int) (logger.Interface, error) { + logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCallerSkip(skip), logger2.WithCaller()} if consoleOutput { logConfList = append(logConfList, logger2.WithConsoleOutput()) } diff --git a/logger/wrapper/http_gin.go b/logger/wrapper/http_gin.go index 64df301..951f813 100644 --- a/logger/wrapper/http_gin.go +++ b/logger/wrapper/http_gin.go @@ -22,12 +22,12 @@ import ( // Author : go_developer@163.com<张德满> // // Date : 3:45 下午 2021/1/3 -func NewGinLogger(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger.RotateLogConfig, extractFieldList []string) (*Gin, error) { +func NewGinLogger(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger.RotateLogConfig, extractFieldList []string, skip int) (*Gin, error) { var ( err error l *zap.Logger ) - logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCaller(), logger2.WithCallerSkip(1)} + logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCaller(), logger2.WithCallerSkip(skip)} if consoleOutput { logConfList = append(logConfList, logger2.WithConsoleOutput()) }