slim trace if depth

This commit is contained in:
gogs 2021-05-02 17:27:20 +08:00
parent 70e93e73d8
commit 5920c33a1c

View File

@ -139,7 +139,11 @@ func (l logger) Error(ctx context.Context, msg string, data ...interface{}) {
// Trace print sql message // Trace print sql message
func (l logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { func (l logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) {
if l.LogLevel > Silent {
if l.LogLevel <= Silent {
return
}
elapsed := time.Since(begin) elapsed := time.Since(begin)
switch { switch {
case err != nil && l.LogLevel >= Error && (!errors.Is(err, ErrRecordNotFound) || !l.IgnoreRecordNotFoundError): case err != nil && l.LogLevel >= Error && (!errors.Is(err, ErrRecordNotFound) || !l.IgnoreRecordNotFoundError):
@ -166,7 +170,6 @@ func (l logger) Trace(ctx context.Context, begin time.Time, fc func() (string, i
} }
} }
} }
}
type traceRecorder struct { type traceRecorder struct {
Interface Interface