Fix recursin error in LoggerFilter
Build rules in constructor to be able to use error log
Otherwise we add rules that are broken and attach to current logger
which will go into endless loop.
@@ -28,16 +28,15 @@ class LoggerFilter(Filter):
def __init__(self, rules: List[Dict], logger: Logger):
super().__init__()
self.logger = logger
- self._rules = rules or []
+ self.rules = self.build_rules(rules or [])
@cached_property
def nrules(self):
return len(self.rules)
- @cached_property
- def rules(self):
+ def build_rules(self, rules):
filters = []
- for rule in self._rules:
+ for rule in rules:
try:
f = FilterRule(**rule)
except TypeError as e:
