From 80b55263d8790beb5bb125f5f7e3995e88b29dd8 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 7 Apr 2021 09:36:15 +0200 Subject: [PATCH] Fix xorm log stack level (#15285) (#15316) Co-authored-by: Lunny Xiao --- models/log.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/models/log.go b/models/log.go index 942dbc744a46..caeab094bd13 100644 --- a/models/log.go +++ b/models/log.go @@ -26,6 +26,8 @@ func NewXORMLogger(showSQL bool) xormlog.Logger { } } +const stackLevel = 8 + // Log a message with defined skip and at logging level func (l *XORMLogBridge) Log(skip int, level log.Level, format string, v ...interface{}) error { return l.logger.Log(skip+1, level, format, v...) @@ -33,42 +35,42 @@ func (l *XORMLogBridge) Log(skip int, level log.Level, format string, v ...inter // Debug show debug log func (l *XORMLogBridge) Debug(v ...interface{}) { - _ = l.Log(2, log.DEBUG, fmt.Sprint(v...)) + _ = l.Log(stackLevel, log.DEBUG, fmt.Sprint(v...)) } // Debugf show debug log func (l *XORMLogBridge) Debugf(format string, v ...interface{}) { - _ = l.Log(2, log.DEBUG, format, v...) + _ = l.Log(stackLevel, log.DEBUG, format, v...) } // Error show error log func (l *XORMLogBridge) Error(v ...interface{}) { - _ = l.Log(2, log.ERROR, fmt.Sprint(v...)) + _ = l.Log(stackLevel, log.ERROR, fmt.Sprint(v...)) } // Errorf show error log func (l *XORMLogBridge) Errorf(format string, v ...interface{}) { - _ = l.Log(2, log.ERROR, format, v...) + _ = l.Log(stackLevel, log.ERROR, format, v...) } // Info show information level log func (l *XORMLogBridge) Info(v ...interface{}) { - _ = l.Log(2, log.INFO, fmt.Sprint(v...)) + _ = l.Log(stackLevel, log.INFO, fmt.Sprint(v...)) } // Infof show information level log func (l *XORMLogBridge) Infof(format string, v ...interface{}) { - _ = l.Log(2, log.INFO, format, v...) + _ = l.Log(stackLevel, log.INFO, format, v...) } // Warn show warning log func (l *XORMLogBridge) Warn(v ...interface{}) { - _ = l.Log(2, log.WARN, fmt.Sprint(v...)) + _ = l.Log(stackLevel, log.WARN, fmt.Sprint(v...)) } // Warnf show warnning log func (l *XORMLogBridge) Warnf(format string, v ...interface{}) { - _ = l.Log(2, log.WARN, format, v...) + _ = l.Log(stackLevel, log.WARN, format, v...) } // Level get logger level