1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 22:39:18 +01:00

fix: Coerce log level to lowercase when guessing in structured json (#2968)

This commit is contained in:
Richard Hull
2024-05-22 14:07:45 +01:00
committed by GitHub
parent b326dca06d
commit 05edd49487
2 changed files with 7 additions and 3 deletions

View File

@@ -44,12 +44,12 @@ func guessLogLevel(logEvent *LogEvent) string {
case map[string]interface{}:
if level, ok := value["level"].(string); ok {
return level
return strings.ToLower(level)
}
case map[string]string:
if level, ok := value["level"]; ok {
return level
return strings.ToLower(level)
}
}

View File

@@ -6,7 +6,7 @@ import (
func TestGuessLogLevel(t *testing.T) {
tests := []struct {
input string
input any
expected string
}{
{"ERROR: Something went wrong", "error"},
@@ -25,6 +25,10 @@ func TestGuessLogLevel(t *testing.T) {
{"[foo] [ ERROR] Something went wrong", "error"},
{"123 ERROR Something went wrong", "error"},
{"123 Something went wrong", ""},
{map[string]interface{}{"level": "info"}, "info"},
{map[string]interface{}{"level": "INFO"}, "info"},
{map[string]string{"level": "info"}, "info"},
{map[string]string{"level": "INFO"}, "info"},
}
for _, test := range tests {