forked from mirror/gorm
Beautify callback log output (#2749)
This commit is contained in:
parent
376a7290d0
commit
0aba7ff3a0
|
@ -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))
|
||||||
|
|
Loading…
Reference in New Issue