1
0
mirror of https://github.com/amir20/dozzle.git synced 2026-01-02 19:17:37 +01:00

Updates logic to find ERROR in logs

This commit is contained in:
Amir Raminfar
2023-03-20 11:13:53 -07:00
parent 15bd0999a2
commit 202b07bfb4
3 changed files with 74 additions and 56 deletions

View File

@@ -130,12 +130,15 @@ var KEY_VALUE_REGEX = regexp.MustCompile(`level=(\w+)`)
func guessLogLevel(logEvent *LogEvent) string {
switch value := logEvent.Message.(type) {
case string:
value = NON_ASCII_REGEX.ReplaceAllString(strings.ToLower(value), "")
levels := []string{"error", "warn", "info", "debug", "trace", "fatal"}
for _, level := range levels {
prefix := regexp.MustCompile("^" + level + "[^a-z]")
if prefix.MatchString(value) {
prefix := regexp.MustCompile("(?i)^" + level + "[^a-z]")
if prefix.MatchString(NON_ASCII_REGEX.ReplaceAllString(value, "")) {
return level
}
if strings.Contains(value, " "+strings.ToUpper(level)+" ") {
return level
}
}