fix: console ts with json number (#115)
This commit is contained in:
parent
8e30c71369
commit
7bcaa1a99e
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue