diff options
-rw-r--r-- | configs/kvmd/platforms/kvmd.v1-hdmi.yaml | 5 | ||||
-rw-r--r-- | configs/kvmd/platforms/kvmd.v1-vga.yaml | 5 | ||||
-rw-r--r-- | kvmd/apps/kvmd/__init__.py | 5 | ||||
-rw-r--r-- | kvmd/logging.py | 19 | ||||
-rw-r--r-- | testenv/kvmd.yaml | 4 |
5 files changed, 11 insertions, 27 deletions
diff --git a/configs/kvmd/platforms/kvmd.v1-hdmi.yaml b/configs/kvmd/platforms/kvmd.v1-hdmi.yaml index 43b3278e..46cbbd37 100644 --- a/configs/kvmd/platforms/kvmd.v1-hdmi.yaml +++ b/configs/kvmd/platforms/kvmd.v1-hdmi.yaml @@ -10,11 +10,6 @@ kvmd: info: meta: /etc/kvmd/meta.yaml - log: - services: - - kvmd.service - - kvmd-tc358743.service - hid: pinout: reset: 4 diff --git a/configs/kvmd/platforms/kvmd.v1-vga.yaml b/configs/kvmd/platforms/kvmd.v1-vga.yaml index 5993176f..dd3ef4db 100644 --- a/configs/kvmd/platforms/kvmd.v1-vga.yaml +++ b/configs/kvmd/platforms/kvmd.v1-vga.yaml @@ -10,11 +10,6 @@ kvmd: info: meta: /etc/kvmd/meta.yaml - log: - services: - - kvmd.service - - kvmd-tc358743.service - hid: pinout: reset: 4 diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py index 103d8be8..155b8141 100644 --- a/kvmd/apps/kvmd/__init__.py +++ b/kvmd/apps/kvmd/__init__.py @@ -22,10 +22,7 @@ def main() -> None: loop = asyncio.get_event_loop() http_session = aiohttp.ClientSession(loop=loop) - log = Log( - services=list(config["log"]["services"]), - loop=loop, - ) + log = Log(loop) hid = Hid( reset=int(config["hid"]["pinout"]["reset"]), diff --git a/kvmd/logging.py b/kvmd/logging.py index 11a8dcf1..70f6f2df 100644 --- a/kvmd/logging.py +++ b/kvmd/logging.py @@ -1,9 +1,9 @@ import sys +import re import asyncio import logging import time -from typing import List from typing import Dict from typing import AsyncGenerator @@ -24,13 +24,7 @@ def get_logger(depth: int=1) -> logging.Logger: class Log: - def __init__( - self, - services: List[str], - loop: asyncio.AbstractEventLoop, - ) -> None: - - self.__services = services + def __init__(self, loop: asyncio.AbstractEventLoop) -> None: self.__loop = loop async def poll_log(self, seek: int, follow: bool) -> AsyncGenerator[Dict, None]: @@ -38,7 +32,14 @@ class Log: reader.this_boot() reader.this_machine() reader.log_level(systemd.journal.LOG_DEBUG) - for service in self.__services: + + services = set( + service + for service in systemd.journal.Reader().query_unique("_SYSTEMD_UNIT") + if re.match(r"kvmd(-\w+)?\.service", service) + ).union(["kvmd.service"]) + + for service in services: reader.add_match(_SYSTEMD_UNIT=service) if seek > 0: reader.seek_realtime(float(time.time() - seek)) diff --git a/testenv/kvmd.yaml b/testenv/kvmd.yaml index 3ab0a25b..9f1f355b 100644 --- a/testenv/kvmd.yaml +++ b/testenv/kvmd.yaml @@ -7,10 +7,6 @@ kvmd: info: meta: /etc/kvmd/meta.yaml - log: - services: - - kvmd.service - hid: pinout: reset: 4 |