fix terminal format (#47718) (#47721)

(cherry picked from commit f62c261900)

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-04-13 17:57:20 +02:00
committed by GitHub
co-authored by ying-jeanne
parent 6aa95a6b86
commit 7366fa2530
+9 -4
View File
@@ -26,8 +26,7 @@ const (
)
func SetTimeFormatGokitLog() {
timeFormat = "2006-01-02T15:04:05.000-0700"
termTimeFormat = "01-02|15:04:05.000"
timeFormat = time.RFC3339Nano
}
type terminalLogger struct {
@@ -104,10 +103,16 @@ func getRecord(keyvals ...interface{}) *record {
if k == "t" {
t, ok := v.(fmt.Stringer)
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 {
r.time = time
r.time = parsedTime
continue
} else {
parsedTime, err := time.Parse(time.RFC3339Nano, t.String())
if err == nil {
r.time = parsedTime
continue
}
}
}