From 0aba7ff3a0bff05dc25ec027895b5e6789e28bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BE=E4=B8=80=E9=A5=BC?= Date: Thu, 5 Dec 2019 18:26:16 +0800 Subject: [PATCH] Beautify callback log output (#2749) --- logger.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/logger.go b/logger.go index a42f2727..b4a362ce 100644 --- a/logger.go +++ b/logger.go @@ -39,6 +39,15 @@ var LogFormatter = func(values ...interface{}) (messages []interface{}) { 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" { // duration messages = append(messages, fmt.Sprintf(" \033[36;1m[%.2fms]\033[0m ", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0))