1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 07:11:29 +00:00

for better performance

This commit is contained in:
JessonChan 2016-03-24 20:27:00 +08:00
parent f02ff0420d
commit 52a0b657b7

View File

@ -597,6 +597,9 @@ func formatLog(f interface{}, v ...interface{}) string {
switch f.(type) { switch f.(type) {
case string: case string:
msg = f.(string) msg = f.(string)
if len(v) == 0 {
return msg
}
if strings.Contains(msg, "%") && !strings.Contains(msg, "%%") { if strings.Contains(msg, "%") && !strings.Contains(msg, "%%") {
//format string //format string
} else { } else {
@ -604,7 +607,11 @@ func formatLog(f interface{}, v ...interface{}) string {
msg += strings.Repeat(" %v", len(v)) msg += strings.Repeat(" %v", len(v))
} }
default: default:
msg = fmt.Sprint(f) + strings.Repeat(" %v", len(v)) msg = fmt.Sprint(f)
if len(v) == 0 {
return msg
}
msg += strings.Repeat(" %v", len(v))
} }
return fmt.Sprintf(msg, v...) return fmt.Sprintf(msg, v...)
} }