1
0
mirror of https://github.com/rs/zerolog synced 2026-06-08 17:13:30 +00:00

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
+4 -1
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)
}