Skip to content

Commit

Permalink
fix gorm log caller skip
Browse files Browse the repository at this point in the history
  • Loading branch information
yinheli committed Jul 15, 2021
1 parent de9e3d5 commit 0a93754
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/gormx/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0a93754

Please sign in to comment.