Skip to content

Commit

Permalink
fixes levels
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed May 22, 2024
1 parent cf232e5 commit 928c170
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/docker/level_guesser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package docker
import (
"regexp"
"strings"

"github.com/iancoleman/orderedmap"
log "github.com/sirupsen/logrus"
)

var keyValueRegex = regexp.MustCompile(`level=(\w+)`)
Expand Down Expand Up @@ -42,15 +45,20 @@ func guessLogLevel(logEvent *LogEvent) string {
return matches[1]
}

case map[string]interface{}:
if level, ok := value["level"].(string); ok {
return strings.ToLower(level)
case *orderedmap.OrderedMap:
if level, ok := value.Get("level"); ok {
if level, ok := level.(string); ok {
return strings.ToLower(level)
}
}

case map[string]string:
if level, ok := value["level"]; ok {
return strings.ToLower(level)
}

default:
log.Debugf("unknown type to guess level: %T", value)
}

return ""
Expand Down

0 comments on commit 928c170

Please sign in to comment.