From 7bcaa1a99e9833acebc006258f934fd699d8bf6a Mon Sep 17 00:00:00 2001 From: Yongzheng Lai Date: Mon, 12 Nov 2018 16:50:17 +0800 Subject: [PATCH] fix: console ts with json number (#115) --- console.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/console.go b/console.go index 5730f75..f25bc32 100644 --- a/console.go +++ b/console.go @@ -292,13 +292,16 @@ func colorize(s interface{}, c int, disabled bool) string { var ( consoleDefaultFormatTimestamp = func(i interface{}) string { t := "" - if tt, ok := i.(string); ok { + switch tt := i.(type) { + case string: ts, err := time.Parse(time.RFC3339, tt) if err != nil { t = tt } else { t = ts.Format(consoleTimeFormat) } + case json.Number: + t = tt.String() } return colorize(t, colorFaint, consoleNoColor) }