fix4791: delay to format parameter
This commit is contained in:
parent
99d26b06b4
commit
fe4b84e4f6
@ -69,6 +69,7 @@
|
||||
- Fix 4759: fix numeric notation of permissions [4759](https://github.com/beego/beego/pull/4759)
|
||||
- set default rate and capacity for ratelimit filter [4796](https://github.com/beego/beego/pull/4796)
|
||||
- Fix 4782: must set status before rendering error page [4797](https://github.com/beego/beego/pull/4797)
|
||||
- Fix 4791: delay to format parameter in log module [4804](https://github.com/beego/beego/pull/4804)
|
||||
|
||||
## Fix Sonar
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ func GetFormatter(name string) (LogFormatter, bool) {
|
||||
return res, ok
|
||||
}
|
||||
|
||||
// 'w' when, 'm' msg,'f' filename,'F' full path,'n' line number
|
||||
// ToString 'w' when, 'm' msg,'f' filename,'F' full path,'n' line number
|
||||
// 'l' level number, 't' prefix of level type, 'T' full name of level type
|
||||
func (p *PatternLogFormatter) ToString(lm *LogMsg) string {
|
||||
s := []rune(p.Pattern)
|
||||
|
||||
@ -705,61 +705,61 @@ func SetLogger(adapter string, config ...string) error {
|
||||
|
||||
// Emergency logs a message at emergency level.
|
||||
func Emergency(f interface{}, v ...interface{}) {
|
||||
beeLogger.Emergency(formatLog(f, v...))
|
||||
beeLogger.Emergency(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Alert logs a message at alert level.
|
||||
func Alert(f interface{}, v ...interface{}) {
|
||||
beeLogger.Alert(formatLog(f, v...))
|
||||
beeLogger.Alert(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Critical logs a message at critical level.
|
||||
func Critical(f interface{}, v ...interface{}) {
|
||||
beeLogger.Critical(formatLog(f, v...))
|
||||
beeLogger.Critical(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Error logs a message at error level.
|
||||
func Error(f interface{}, v ...interface{}) {
|
||||
beeLogger.Error(formatLog(f, v...))
|
||||
beeLogger.Error(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Warning logs a message at warning level.
|
||||
func Warning(f interface{}, v ...interface{}) {
|
||||
beeLogger.Warn(formatLog(f, v...))
|
||||
beeLogger.Warn(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Warn compatibility alias for Warning()
|
||||
func Warn(f interface{}, v ...interface{}) {
|
||||
beeLogger.Warn(formatLog(f, v...))
|
||||
beeLogger.Warn(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Notice logs a message at notice level.
|
||||
func Notice(f interface{}, v ...interface{}) {
|
||||
beeLogger.Notice(formatLog(f, v...))
|
||||
beeLogger.Notice(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Informational logs a message at info level.
|
||||
func Informational(f interface{}, v ...interface{}) {
|
||||
beeLogger.Info(formatLog(f, v...))
|
||||
beeLogger.Info(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Info compatibility alias for Warning()
|
||||
func Info(f interface{}, v ...interface{}) {
|
||||
beeLogger.Info(formatLog(f, v...))
|
||||
beeLogger.Info(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Debug logs a message at debug level.
|
||||
func Debug(f interface{}, v ...interface{}) {
|
||||
beeLogger.Debug(formatLog(f, v...))
|
||||
beeLogger.Debug(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
// Trace logs a message at trace level.
|
||||
// compatibility alias for Warning()
|
||||
func Trace(f interface{}, v ...interface{}) {
|
||||
beeLogger.Trace(formatLog(f, v...))
|
||||
beeLogger.Trace(formatPattern(f, v...), v...)
|
||||
}
|
||||
|
||||
func formatLog(f interface{}, v ...interface{}) string {
|
||||
func formatPattern(f interface{}, v ...interface{}) string {
|
||||
var msg string
|
||||
switch f.(type) {
|
||||
case string:
|
||||
@ -778,5 +778,5 @@ func formatLog(f interface{}, v ...interface{}) string {
|
||||
}
|
||||
msg += strings.Repeat(" %v", len(v))
|
||||
}
|
||||
return fmt.Sprintf(msg, v...)
|
||||
return msg
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user