LogTrigger: fixed substrings output

This commit is contained in:
2025-03-29 16:37:05 +01:00
parent ed8aef1e40
commit 798d25e75c
2 changed files with 14 additions and 5 deletions
+13 -4
View File
@@ -20,9 +20,15 @@ class TriggerString:
@cached_property
def substrings(self) -> list[str]:
_substrings = []
if 'substrings' in self.json_data:
return self.json_data['substrings']['substring']
return []
if isinstance(self.json_data['substrings']['substring'], list):
_substrings.extend(self.json_data['substrings'])
elif isinstance(self.json_data['substrings']['substring'], str):
_substrings.append(self.json_data['substrings']['substring'])
else:
raise ValueError("substrings must be a list or a string")
return _substrings
@cached_property
def condition(self) -> str:
@@ -69,12 +75,15 @@ class LogTrigger(Trigger):
self.timestamp_last_active_change = datetime.now()
if not self.active:
self.log.info("activating trigger, log file: %s, trigger strings: %s, governor: %s", self.file, self.trigger_strings, self.governor.name)
self.active = True
self.active = True
self.log.info("Statistics: %s", self.get_statistic_info())
def set_inactive(self) -> None:
if self.active:
self.log.info("deactivating trigger, log file: %s, trigger strings: %s, governor: %s", self.file, self.trigger_strings, self.governor.name)
self.active = False
self.active = False
self.log.info("Statistics: %s", self.get_statistic_info())
def _process_line(self, line: str) -> None:
for trigger_string in self.trigger_strings: