[systemd-devel] python - reading the journal
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Sun Feb 3 18:07:23 PST 2013
On Sun, Feb 03, 2013 at 09:18:28PM +0000, Steven Hiscocks wrote:
> Hi,
>
> I've been developing a python module for accessing the journal,
> using the journal API. (https://github.com/kwirk/pyjournalctl)
Great! Have you thought about including it in the systemd repo,
once interface nad implementation is stabilized?
> One issue I've had is with 'sd_journal_seek_monotonic_usec'. When
> called, followed by call to 'sd_journal_next', I end up at the start
> of the journal.
> If I set a match for "_BOOT_ID" , before (or after) the call to
> 'sd_journal_seek_monotonic_usec' (with same "_BOOT_ID"), it then
> behaves as I would expect and returns the closest log entry to the
> monotonic time stamp.
>
> I was wondering if this is this the intended behaviour, or is this a bug?
Looking at the docs, it seems OK. Without _BOOT_ID the behaviour
is unspecified.
Some comments about the API:
>>> journal.add_match("PRIORITY", "5")
Why not journal.add_match(PRIORITY="5") ?
Likewise journal.add_matches({"PRIORITY": "5", "_PID": "1"})
could be written as journal.add_matches(PRIORITY=5, _PID=1).
This would mirror the journal API which is part of the python-systemd
module.
Note: systemd.journal already has LOG_EMERG and friends (imported
from syslog), so there's no need to use plain numbers.
Your object-oriented approach, python 2/3 compatiblity, GIL releasing
support are great. I would definitely want to pull this into the
python-systemd.
Zbyszek
More information about the systemd-devel
mailing list