Skip to content

Commit

Permalink
Fix logger check LogLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jan 6, 2021
1 parent 5e72cd9 commit bf0fd9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (l logger) Error(ctx context.Context, msg string, data ...interface{}) {

// Trace print sql message
func (l logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) {
if l.LogLevel > 0 {
if l.LogLevel > Silent {
elapsed := time.Since(begin)
switch {
case err != nil && l.LogLevel >= Error:
Expand All @@ -153,7 +153,7 @@ func (l logger) Trace(ctx context.Context, begin time.Time, fc func() (string, i
} else {
l.Printf(l.traceWarnStr, utils.FileWithLineNum(), slowLog, float64(elapsed.Nanoseconds())/1e6, rows, sql)
}
case l.LogLevel >= Info:
default:
sql, rows := fc()
if rows == -1 {
l.Printf(l.traceStr, utils.FileWithLineNum(), float64(elapsed.Nanoseconds())/1e6, "-", sql)
Expand Down

0 comments on commit bf0fd9b

Please sign in to comment.