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 (
consoleDefaultFormatTimestamp = func(i interface{}) string {
t := "<nil>"
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)
}