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:
@@ -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
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user