fix: console ts with json number (#115)

This commit is contained in:
Yongzheng Lai 2018-11-12 16:50:17 +08:00 committed by Olivier Poitrey
parent 8e30c71369
commit 7bcaa1a99e
1 changed files with 4 additions and 1 deletions

View File

@ -292,13 +292,16 @@ func colorize(s interface{}, c int, disabled bool) string {
var ( var (
consoleDefaultFormatTimestamp = func(i interface{}) string { consoleDefaultFormatTimestamp = func(i interface{}) string {
t := "<nil>" t := "<nil>"
if tt, ok := i.(string); ok { switch tt := i.(type) {
case string:
ts, err := time.Parse(time.RFC3339, tt) ts, err := time.Parse(time.RFC3339, tt)
if err != nil { if err != nil {
t = tt t = tt
} else { } else {
t = ts.Format(consoleTimeFormat) t = ts.Format(consoleTimeFormat)
} }
case json.Number:
t = tt.String()
} }
return colorize(t, colorFaint, consoleNoColor) return colorize(t, colorFaint, consoleNoColor)
} }