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,6 +205,12 @@ func (s *namespaceSource) handleLine(l []byte, pod string) {
if site == "" { if site == "" {
site = line.Caller site = line.Caller
} }
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 // 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", msg := fmt.Sprintf("%s %s %s [%s] [%s] %s",
strings.ToUpper(string(line.Level[0])), strings.ToUpper(string(line.Level[0])),
@ -219,6 +225,7 @@ func (s *namespaceSource) handleLine(l []byte, pod string) {
} }
logf(msg) logf(msg)
}()
} }
} }