Enhance db.Scan with ParamsFilter - Issue 7336 - Suggestion (#7337)
This commit is contained in:
parent
8503287ca4
commit
fed49230cb
@ -80,6 +80,11 @@ var (
|
|||||||
})
|
})
|
||||||
// Recorder logger records running SQL into a recorder instance
|
// Recorder logger records running SQL into a recorder instance
|
||||||
Recorder = traceRecorder{Interface: Default, BeginAt: time.Now()}
|
Recorder = traceRecorder{Interface: Default, BeginAt: time.Now()}
|
||||||
|
|
||||||
|
// RecorderParamsFilter defaults to no-op, allows to be run-over by a different implementation
|
||||||
|
RecorderParamsFilter = func(ctx context.Context, sql string, params ...interface{}) (string, []interface{}) {
|
||||||
|
return sql, params
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// New initialize logger
|
// New initialize logger
|
||||||
@ -211,3 +216,10 @@ func (l *traceRecorder) Trace(ctx context.Context, begin time.Time, fc func() (s
|
|||||||
l.SQL, l.RowsAffected = fc()
|
l.SQL, l.RowsAffected = fc()
|
||||||
l.Err = err
|
l.Err = err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *traceRecorder) ParamsFilter(ctx context.Context, sql string, params ...interface{}) (string, []interface{}) {
|
||||||
|
if RecorderParamsFilter == nil {
|
||||||
|
return sql, params
|
||||||
|
}
|
||||||
|
return RecorderParamsFilter(ctx, sql, params...)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user