- _convert_unicode = functools.partial(unicode, encoding='utf-8')
-
-class Journal(_Journal):
- def __init__(self, converters=None, *args, **kwargs):
- super(Journal, self).__init__(*args, **kwargs)
- if sys.version_info >= (3,3):
- self.converters = ChainMap()
+ _convert_unicode = _functools.partial(unicode, encoding='utf-8')
+
+class Reader(_Reader):
+ """Reader allows the access and filtering of systemd journal
+ entries. Note that in order to access the system journal, a
+ non-root user must be in the `adm` group.
+
+ Example usage to print out all error or higher level messages
+ for systemd-udevd for the boot:
+
+ >>> myjournal = journal.Reader()
+ >>> myjournal.add_boot_match(journal.CURRENT_BOOT)
+ >>> myjournal.add_loglevel_matches(journal.LOG_ERR)
+ >>> myjournal.add_match(_SYSTEMD_UNIT="systemd-udevd.service")
+ >>> for entry in myjournal:
+ ... print(entry['MESSAGE'])
+
+ See systemd.journal-fields(7) for more info on typical fields
+ found in the journal.
+ """
+ def __init__(self, converters=None, flags=LOCAL_ONLY, path=None):
+ """Create an instance of Reader, which allows filtering and
+ return of journal entries.
+ Argument `converters` is a dictionary which updates the
+ DEFAULT_CONVERTERS to convert journal field values.
+ Argument `flags` sets open flags of the journal, which can be one
+ of, or ORed combination of constants: LOCAL_ONLY (default) opens
+ journal on local machine only; RUNTIME_ONLY opens only
+ volatile journal files; and SYSTEM_ONLY opens only
+ journal files of system services and the kernel.
+ Argument `path` is the directory of journal files. Note that
+ currently flags are ignored when `path` is present as they are
+ currently not relevant.
+ """
+ super(Reader, self).__init__(flags, path)
+ if _sys.version_info >= (3,3):
+ self.converters = _ChainMap()