Added exclude_filter #136

Merged
abereziny merged 1 commit from :bug/log_analyzer_exception_for_ft into master 2023-12-01 12:55:51 +00:00
2 changed files with 6 additions and 0 deletions

View file

@ -235,6 +235,7 @@ class DockerHost(Host):
since: Optional[datetime] = None,
until: Optional[datetime] = None,
unit: Optional[str] = None,
exclude_filter: Optional[str] = None,
) -> str:
client = self._get_docker_client()
filtered_logs = ""
@ -248,6 +249,10 @@ class DockerHost(Host):
matches = re.findall(filter_regex, filtered_logs, re.IGNORECASE + re.MULTILINE)
found = list(matches)
if exclude_filter:
found = [match for match in found if match != exclude_filter]
if found:
filtered_logs += f"{container_name}:\n{os.linesep.join(found)}"

View file

@ -287,6 +287,7 @@ class Host(ABC):
since: Optional[datetime] = None,
until: Optional[datetime] = None,
unit: Optional[str] = None,
exclude_filter: Optional[str] = None,
) -> str:
"""Get logs from host filtered by regex.