Log if the deserialized line is semi-normal. (#1939)

Right now they panic and we lose all the context.
This commit is contained in:
Victor Agababov 2020-12-04 09:55:09 -08:00 committed by GitHub
parent b89ac2a632
commit c9bac6be76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 12 deletions

View File

@ -205,20 +205,27 @@ func (s *namespaceSource) handleLine(l []byte, pod string) {
if site == "" {
site = line.Caller
}
// E 15:04:05.000 webhook-699b7b668d-9smk2 [route-controller] [default/testroute-xyz] this is my message
msg := fmt.Sprintf("%s %s %s [%s] [%s] %s",
strings.ToUpper(string(line.Level[0])),
line.Timestamp.Format(timeFormat),
pod,
site,
line.Key,
line.Message)
func() {
defer func() {
if err := recover(); err != nil {
logf("Invalid log format for pod %s: %s", pod, string(l))
}
}()
// E 15:04:05.000 webhook-699b7b668d-9smk2 [route-controller] [default/testroute-xyz] this is my message
msg := fmt.Sprintf("%s %s %s [%s] [%s] %s",
strings.ToUpper(string(line.Level[0])),
line.Timestamp.Format(timeFormat),
pod,
site,
line.Key,
line.Message)
if line.Error != "" {
msg += " err=" + line.Error
}
if line.Error != "" {
msg += " err=" + line.Error
}
logf(msg)
logf(msg)
}()
}
}