[#136] Added exclude_filter

Added exclude_filter

Signed-off-by: Mikhail Kadilov <m.kadilov@yadro.com>
master
Mikhail Kadilov 2023-12-01 15:54:28 +03:00 committed by Andrey Berezin
parent dc6b0e407f
commit 17c1a4f14b
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.