Skip to content

Commit

Permalink
Merge branch 'zap_loglevel' into fork
Browse files Browse the repository at this point in the history
  • Loading branch information
jum committed Aug 29, 2024
2 parents 8d2f638 + 97fd652 commit 989c7fb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ngcplogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@ func (l *nGCPLogger) extractSeverityFromPayload(m map[string]any) logging.Severi
if l.extractSeverity {
for _, severityField := range severityFields {
if rawSeverity, exists := m[severityField]; exists {
// check for some zap severity levels and translate
switch rawSeverity {
case "warn":
rawSeverity = "warning"
case "dpanic":
fallthrough
case "panic":
rawSeverity = "critical"
case "fatal":
rawSeverity = "alert"
}
if parsedSeverity, isString := rawSeverity.(string); isString {
severity = logging.ParseSeverity(parsedSeverity)
if severity != logging.Default { // severity was parsed correctly, we can remove it from the jsonPayload section
Expand Down

0 comments on commit 989c7fb

Please sign in to comment.