Beautify callback log output (#2749)

This commit is contained in:
贾一饼 2019-12-05 18:26:16 +08:00 committed by Jinzhu
parent 376a7290d0
commit 0aba7ff3a0
1 changed files with 9 additions and 0 deletions

View File

@ -39,6 +39,15 @@ var LogFormatter = func(values ...interface{}) (messages []interface{}) {
messages = []interface{}{source, currentTime} messages = []interface{}{source, currentTime}
if len(values) == 2 {
//remove the line break
currentTime = currentTime[1:]
//remove the brackets
source = fmt.Sprintf("\033[35m%v\033[0m", values[1])
messages = []interface{}{currentTime, source}
}
if level == "sql" { if level == "sql" {
// duration // duration
messages = append(messages, fmt.Sprintf(" \033[36;1m[%.2fms]\033[0m ", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0)) messages = append(messages, fmt.Sprintf(" \033[36;1m[%.2fms]\033[0m ", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0))