From 0a93754e9e8cfb93640e8ae12870c753c3065377 Mon Sep 17 00:00:00 2001 From: yinheli Date: Fri, 16 Jul 2021 01:39:53 +0800 Subject: [PATCH] fix gorm log caller skip --- pkg/gormx/logger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gormx/logger.go b/pkg/gormx/logger.go index ee9e8c3..28304f3 100644 --- a/pkg/gormx/logger.go +++ b/pkg/gormx/logger.go @@ -34,7 +34,7 @@ func (t *dbLogger) Error(ctx context.Context, msg string, data ...interface{}) { } func (t *dbLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) { - l := t.logger.For(ctx).CallerSkip(2) + l := t.logger.For(ctx).CallerSkip(4) sql, rows := fc() l = l.With(zap.Duration("elapsed", time.Since(begin)), zap.Int64("rows", rows)) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {