summaryrefslogtreecommitdiff
path: root/src/python-systemd/journal.py
diff options
context:
space:
mode:
authorSteven Hiscocks <steven@hiscocks.me.uk>2013-02-15 17:16:56 +0000
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-02-22 16:57:43 +0100
commit6a71de70e5f5a244b656d9ccb373cc7241033e15 (patch)
treedc50436866c7290888a77b0e0e1c444ee575c913 /src/python-systemd/journal.py
parent25523db4e1a3da09916ed69c1e90a52d027ac765 (diff)
systemd-python: implement this_boot/this_machine in Python
Diffstat (limited to 'src/python-systemd/journal.py')
-rw-r--r--src/python-systemd/journal.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/python-systemd/journal.py b/src/python-systemd/journal.py
index 40e40c360b..533a8754a4 100644
--- a/src/python-systemd/journal.py
+++ b/src/python-systemd/journal.py
@@ -31,6 +31,7 @@ from syslog import (LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR,
from ._journal import sendv, stream_fd
from ._reader import (_Journal, NOP, APPEND, INVALIDATE,
LOCAL_ONLY, RUNTIME_ONLY, SYSTEM_ONLY)
+from . import id128 as _id128
_MONOTONIC_CONVERTER = lambda x: datetime.timedelta(microseconds=float(x))
_REALTIME_CONVERTER = lambda x: datetime.datetime.fromtimestamp(float(x)/1E6)
@@ -123,6 +124,14 @@ class Journal(_Journal):
else:
raise ValueError("Log level must be 0 <= level <= 7")
+ def this_boot(self):
+ """Add match for _BOOT_ID equal to current boot ID."""
+ self.add_match(_BOOT_ID=_id128.get_boot().hex)
+
+ def this_machine(self):
+ """Add match for _MACHINE_ID equal to the ID of this machine."""
+ self.add_match(_MACHINE_ID=_id128.get_machine().hex)
+
def _make_line(field, value):
if isinstance(value, bytes):
return field.encode('utf-8') + b'=' + value