Logging: Fix so that filters can contain commented lines (#45159)

Fixes log filters that contains comments should not be enabled
This commit is contained in:
Marcus Efraimsson
2022-02-10 09:52:37 +01:00
committed by GitHub
parent 88cf2da12e
commit 2082eeb72f
2 changed files with 81 additions and 1 deletions
+10 -1
View File
@@ -251,7 +251,16 @@ func getLogLevelFromString(levelName string) level.Option {
func getFilters(filterStrArray []string) map[string]level.Option {
filterMap := make(map[string]level.Option)
for _, filterStr := range filterStrArray {
for i := 0; i < len(filterStrArray); i++ {
filterStr := strings.TrimSpace(filterStrArray[i])
if strings.HasPrefix(filterStr, ";") || strings.HasPrefix(filterStr, "#") {
if len(filterStr) == 1 {
i++
}
continue
}
parts := strings.Split(filterStr, ":")
if len(parts) > 1 {
filterMap[parts[0]] = getLogLevelFromString(parts[1])