Skip to content

Commit

Permalink
feat: handle log levels with double quotes (#3519)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesGit1 authored Jan 7, 2025
1 parent cbbe5f7 commit 5c33f44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/docker/level_guesser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions internal/docker/level_guesser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 5c33f44

Please sign in to comment.