1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-27 15:41:45 +01:00

feat: handle log levels with double quotes (#3519)

This commit is contained in:
James Shaw
2025-01-07 16:55:38 +00:00
committed by GitHub
parent cbbe5f7571
commit 5c33f4437e
2 changed files with 9 additions and 0 deletions

View File

@@ -67,6 +67,11 @@ func guessLogLevel(logEvent *LogEvent) string {
}
}
// Look for the level in the middle of the message that are uppercase and surrounded by quotes
if strings.Contains(value, "\""+strings.ToUpper(first)+"\"") {
return first
}
// Look for the level in the middle of the message that are uppercase
if strings.Contains(value, " "+strings.ToUpper(first)+" ") {
return first

View File

@@ -15,6 +15,10 @@ func TestGuessLogLevel(t *testing.T) {
}{
{"2024/12/30 12:21AM INF this is a test", "info"},
{"2024-12-30T17:43:16Z DBG loggging debug from here", "debug"},
{"2025-01-07 15:40:15,784 LL=\"ERROR\" some message", "error"},
{"2025-01-07 15:40:15,784 LL=\"WARN\" some message", "warn"},
{"2025-01-07 15:40:15,784 LL=\"INFO\" some message", "info"},
{"2025-01-07 15:40:15,784 LL=\"DEBUG\" some message", "debug"},
{"ERROR: Something went wrong", "error"},
{"WARN: Something might be wrong", "warn"},
{"INFO: Something happened", "info"},