mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-27 07:31:46 +01:00
fix: supports searching for int, float and boolean (#3247)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package search
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -61,14 +62,8 @@ func searchMapAny(re *regexp.Regexp, orderedMap *orderedmap.OrderedMap[string, a
|
||||
}
|
||||
|
||||
case []any:
|
||||
for i, v := range value {
|
||||
switch v := v.(type) {
|
||||
case string:
|
||||
if re.MatchString(v) {
|
||||
found = true
|
||||
value[i] = re.ReplaceAllString(v, "<mark>$0</mark>")
|
||||
}
|
||||
}
|
||||
if searchArray(re, value) {
|
||||
found = true
|
||||
}
|
||||
|
||||
case *orderedmap.OrderedMap[string, any]:
|
||||
@@ -86,6 +81,13 @@ func searchMapAny(re *regexp.Regexp, orderedMap *orderedmap.OrderedMap[string, a
|
||||
found = true
|
||||
}
|
||||
|
||||
case int, float64, bool:
|
||||
formatted := fmt.Sprintf("%v", value)
|
||||
if re.MatchString(formatted) {
|
||||
orderedMap.Set(pair.Key, re.ReplaceAllString(formatted, "<mark>$0</mark>"))
|
||||
found = true
|
||||
}
|
||||
|
||||
default:
|
||||
log.Debug().Type("type", value).Msg("unknown logEvent type inside searchMapAny")
|
||||
}
|
||||
@@ -105,14 +107,8 @@ func searchMap(re *regexp.Regexp, data map[string]interface{}) bool {
|
||||
}
|
||||
|
||||
case []any:
|
||||
for i, v := range value {
|
||||
switch v := v.(type) {
|
||||
case string:
|
||||
if re.MatchString(v) {
|
||||
found = true
|
||||
value[i] = re.ReplaceAllString(v, "<mark>$0</mark>")
|
||||
}
|
||||
}
|
||||
if searchArray(re, value) {
|
||||
found = true
|
||||
}
|
||||
|
||||
case map[string]interface{}:
|
||||
@@ -120,6 +116,12 @@ func searchMap(re *regexp.Regexp, data map[string]interface{}) bool {
|
||||
found = true
|
||||
}
|
||||
|
||||
case int, float64, bool:
|
||||
formatted := fmt.Sprintf("%v", value)
|
||||
if re.MatchString(formatted) {
|
||||
data[key] = re.ReplaceAllString(formatted, "<mark>$0</mark>")
|
||||
found = true
|
||||
}
|
||||
default:
|
||||
log.Debug().Type("type", value).Msg("unknown logEvent type inside searchMap")
|
||||
}
|
||||
@@ -138,3 +140,32 @@ func searchMapString(re *regexp.Regexp, orderedMap *orderedmap.OrderedMap[string
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
func searchArray(re *regexp.Regexp, data []any) bool {
|
||||
found := false
|
||||
for i, value := range data {
|
||||
switch value := value.(type) {
|
||||
case string:
|
||||
if re.MatchString(value) {
|
||||
data[i] = re.ReplaceAllString(value, "<mark>$0</mark>")
|
||||
found = true
|
||||
}
|
||||
case int, float64, bool:
|
||||
formatted := fmt.Sprintf("%v", value)
|
||||
if re.MatchString(formatted) {
|
||||
data[i] = re.ReplaceAllString(formatted, "<mark>$0</mark>")
|
||||
found = true
|
||||
}
|
||||
case []any:
|
||||
if searchArray(re, value) {
|
||||
found = true
|
||||
}
|
||||
case map[string]interface{}:
|
||||
if searchMap(re, value) {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return found
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user