Fix logger check LogLevel
This commit is contained in:
		
							parent
							
								
									5e72cd9a2b
								
							
						
					
					
						commit
						bf0fd9bef6
					
				| @ -135,7 +135,7 @@ 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 > 0 { | 	if l.LogLevel > Silent { | ||||||
| 		elapsed := time.Since(begin) | 		elapsed := time.Since(begin) | ||||||
| 		switch { | 		switch { | ||||||
| 		case err != nil && l.LogLevel >= Error: | 		case err != nil && l.LogLevel >= Error: | ||||||
| @ -153,7 +153,7 @@ func (l logger) Trace(ctx context.Context, begin time.Time, fc func() (string, i | |||||||
| 			} else { | 			} else { | ||||||
| 				l.Printf(l.traceWarnStr, utils.FileWithLineNum(), slowLog, float64(elapsed.Nanoseconds())/1e6, rows, sql) | 				l.Printf(l.traceWarnStr, utils.FileWithLineNum(), slowLog, float64(elapsed.Nanoseconds())/1e6, rows, sql) | ||||||
| 			} | 			} | ||||||
| 		case l.LogLevel >= Info: | 		default: | ||||||
| 			sql, rows := fc() | 			sql, rows := fc() | ||||||
| 			if rows == -1 { | 			if rows == -1 { | ||||||
| 				l.Printf(l.traceStr, utils.FileWithLineNum(), float64(elapsed.Nanoseconds())/1e6, "-", sql) | 				l.Printf(l.traceStr, utils.FileWithLineNum(), float64(elapsed.Nanoseconds())/1e6, "-", sql) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jinzhu
						Jinzhu