Debian Codegraph @

tests/tracer_test.go

raw
1 package tests_test
2
3 import (
4 "context"
5 "time"
6
7 "gorm.io/gorm/logger"
8 )
9
10 type Tracer struct {
11 Logger logger.Interface
12 Test func(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)
13 }
14
15 func (S Tracer) LogMode(level logger.LogLevel) logger.Interface {
16 return S.Logger.LogMode(level)
17 }
18
19 func (S Tracer) Info(ctx context.Context, s string, i ...interface{}) {
20 S.Logger.Info(ctx, s, i...)
21 }
22
23 func (S Tracer) Warn(ctx context.Context, s string, i ...interface{}) {
24 S.Logger.Warn(ctx, s, i...)
25 }
26
27 func (S Tracer) Error(ctx context.Context, s string, i ...interface{}) {
28 S.Logger.Error(ctx, s, i...)
29 }
30
31 func (S Tracer) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) {
32 S.Logger.Trace(ctx, begin, fc, err)
33 S.Test(ctx, begin, fc, err)
34 }