mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
Logger: avoid panic when time is a string (not fmt.Stringer) (#44497)
This commit is contained in:
parent
8a7b469679
commit
3c334cd8ba
@ -91,13 +91,25 @@ func getRecord(keyvals ...interface{}) *record {
|
|||||||
k, v := keyvals[i], keyvals[i+1]
|
k, v := keyvals[i], keyvals[i+1]
|
||||||
|
|
||||||
if k == "t" {
|
if k == "t" {
|
||||||
t := v.(fmt.Stringer)
|
t, ok := v.(fmt.Stringer)
|
||||||
|
if ok {
|
||||||
time, err := time.Parse("2006-01-02T15:04:05.999999999-0700", t.String())
|
time, err := time.Parse("2006-01-02T15:04:05.999999999-0700", t.String())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
r.time = time
|
r.time = time
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t3, ok := v.(string)
|
||||||
|
if ok {
|
||||||
|
// from alerting: 2022-01-26T12:03:41.655107858-08:00
|
||||||
|
time, err := time.Parse("2006-01-02T15:04:05.999999999-07:00", t3)
|
||||||
|
if err == nil {
|
||||||
|
r.time = time
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if keyvals[i] == "msg" {
|
if keyvals[i] == "msg" {
|
||||||
r.msg = v.(string)
|
r.msg = v.(string)
|
||||||
|
Loading…
Reference in New Issue
Block a user