fix terminal format (#47718)

This commit is contained in:
ying-jeanne 2022-04-13 17:37:56 +02:00 committed by GitHub
parent dfdfe3f428
commit f62c261900
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,8 +26,7 @@ const (
) )
func SetTimeFormatGokitLog() { func SetTimeFormatGokitLog() {
timeFormat = "2006-01-02T15:04:05.000-0700" timeFormat = time.RFC3339Nano
termTimeFormat = "01-02|15:04:05.000"
} }
type terminalLogger struct { type terminalLogger struct {
@ -104,10 +103,16 @@ func getRecord(keyvals ...interface{}) *record {
if k == "t" { if k == "t" {
t, ok := v.(fmt.Stringer) t, ok := v.(fmt.Stringer)
if ok { if ok {
time, err := time.Parse("2006-01-02T15:04:05.999999999-0700", t.String()) parsedTime, err := time.Parse("2006-01-02T15:04:05.999999999-0700", t.String())
if err == nil { if err == nil {
r.time = time r.time = parsedTime
continue continue
} else {
parsedTime, err := time.Parse(time.RFC3339Nano, t.String())
if err == nil {
r.time = parsedTime
continue
}
} }
} }