-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathxorm.go
22 lines (18 loc) · 815 Bytes
/
xorm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package logs
// db.AddHook(&repoHook{showSql: true})
// type repoHook struct {
// showSql bool
// }
// func (rh *repoHook) BeforeProcess(ctx *contexts.ContextHook) (context.Context, error) {
// return ctx.Ctx, nil
// }
// func (rh *repoHook) AfterProcess(ctx *contexts.ContextHook) error {
// if ctx.Err != nil {
// logs.Ctx(ctx.Ctx).Caller(false).Err(ctx.Err).Str("SQL", ctx.SQL).Any("args", ctx.Args).Dur("dur", ctx.ExecuteTime).Error()
// } else if ctx.ExecuteTime > 200*time.Millisecond {
// logs.Ctx(ctx.Ctx).Caller(false).Str("SlowSQL", ctx.SQL).Any("args", ctx.Args).Dur("dur", ctx.ExecuteTime).Warn()
// } else if rh.showSql {
// logs.Ctx(ctx.Ctx).Caller(false).Str("SQL", ctx.SQL).Any("args", ctx.Args).Dur("dur", ctx.ExecuteTime).Debug()
// }
// return ctx.Err
// }