Skip to content

Commit 0aba7ff

Browse files
liovjinzhu
authored andcommitted
Beautify callback log output (go-gorm#2749)
1 parent 376a729 commit 0aba7ff

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

logger.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ var LogFormatter = func(values ...interface{}) (messages []interface{}) {
3939

4040
messages = []interface{}{source, currentTime}
4141

42+
if len(values) == 2 {
43+
//remove the line break
44+
currentTime = currentTime[1:]
45+
//remove the brackets
46+
source = fmt.Sprintf("\033[35m%v\033[0m", values[1])
47+
48+
messages = []interface{}{currentTime, source}
49+
}
50+
4251
if level == "sql" {
4352
// duration
4453
messages = append(messages, fmt.Sprintf(" \033[36;1m[%.2fms]\033[0m ", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0))

0 commit comments

Comments
 (0)