summaryrefslogtreecommitdiff
path: root/kvmd/logging.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-11-17 11:20:10 +0300
committerDevaev Maxim <[email protected]>2018-11-17 11:20:10 +0300
commit43f161f9c4a39fae1538cc300237f8a62648dc86 (patch)
tree88bde2b1966309a1a87dcbe103b483c922293efd /kvmd/logging.py
parent0bf39f56e26268b68bb598ae06f6f91cc3bdc0f4 (diff)
automatic choosing journald services
Diffstat (limited to 'kvmd/logging.py')
-rw-r--r--kvmd/logging.py19
1 files changed, 10 insertions, 9 deletions
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))