| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
One usage of `connection_error` got missed when dropping Python 2 support.
|
| |
|
|
|
|
| |
Fixes #118.
|
|
|
|
|
| |
'import foo as _foo' is useful in exported modules to avoid 'foo' being
present in the public API. No need to play that game in test code.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a lazy workaround: 4c9a241949067fc8d55f3ea12170ad364bd8b18d
is amended to do nothing on python2, so we have the same issue that
was present before. This allows the code to execute, and hopefully
almost nobody is using python2 code anyway.
f868a56b935b6152d611b22f7a5538f14dafb194 is amended in the same way.
For python2 code we have the same lack of timezone-awareness as before.
This allows the tests to pass under python 2.7.
|
|\
| |
| | |
Support realtime cutoff access
|
| | |
|
| | |
|
| | |
|
| | |
|
|/ |
|
|
|
|
|
|
|
| |
"after some quick testing, the execution time got halved (32-ish
seconds to 16-ish seconds) when going through all journal entries."
Closes #63.
|
|
|
|
| |
Add log namespace support which is added since systemd v245
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
positional param
This change enables to add extra fields to JournalHandler in a
configuration file loaded by `logging.config.fileConfig`, which only allows positional
parameters:
class=systemd.journal.JournalHandler
args={'level': INFO, 'SYSLOG_IDENTIFIER': 'my-cool-app'}
[zj: originally the patch added a new positional parameter to
__init__(), but that is not backwards compatible. So I added a new
classmethod to allow the positional parameters to be passed.]
|
|
|
|
|
|
| |
When running the tests in Fedora's mock, the test would
fail because NOTIFY_SOCKET is set to /run/systemd/nspawn/notify, and
we get a permission error.
|
| |
|
| |
|
|
|
|
|
| |
`strftime("%s")` is not in the official python documentation but in my system (ubuntu 18.04 python 3.6.9) it is not aware of the object timezone and will return the wrong value if the timezone is specified and is not the system local one.
There are multiple ways to ensure a python `datetime.datetime` is in local timezone, the easiest (with python 3.3+) is to call `.astimezone()` If one wants to support earlier versions of python an extra dependency might be needed like `dateutil.tz.tzlocal()`.
|
| |
|
|
|
|
|
| |
Together with the previous commit, this makes it much easier to find
the right docs. Fixes #48.
|
|
|
|
|
| |
See https://github.com/sphinx-doc/sphinx/pull/4235 for the :manpage:
role.
|
|
|
|
|
| |
This has the advantage that it is slightly less verbose, and
also any potential typos in the macro names are immediately detected.
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
There doesn't seem to be any particular need to do this.
Also remove unused uuid variable.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
The example relies on implementation details, but I don't see
why it wouldn't work everywhere. Let's pull it in, and if it breaks
somewhere, we can remove it.
|
|\
| |
| | |
Fix notify fs leak
|
| | |
|
| | |
|
|/ |
|
|
|
|
|
|
|
| |
In systemd-233 the format of the constants file changed to use
SD_ID128_MAKE_STR macro and long lines are broken with '\'.
Doing this in sed is too anyoing — add a simple python script to
do the processing.
|
|
|
|
|
|
| |
We get <systemd.journal.JournalHandler object at ...> in older versions,
and <JournalHandler (NOTSET)> in since Python 3.6.
https://github.com/python/cpython/commit/c0752011472790e34d171b89f4b862cc3fd8ad08
|
|
|
|
|
|
| |
send() already does conversions in a type-specific way, and doing it
in journal handler would defeat those conversions. In particular, UUIDs
would be converted to early and have dashes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
MESSAGE_ID passing was broken before previous commit:
TypeError: send() got multiple values for keyword argument 'MESSAGE_ID'
With the previous commit it's broken differently:
______________________________ test_journalhandler_message_id_on_handler _______________________________
def test_journalhandler_message_id_on_handler():
record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None)
sender = MockSender()
handler = journal.JournalHandler(logging.INFO, sender_function=sender.send,
MESSAGE_ID=TEST_MID)
handler.emit(record)
assert len(sender.buf) == 1
> assert 'MESSAGE_ID=' + TEST_MID.hex in sender.buf[0]
E assert ('MESSAGE_ID=' + '8441372f8dca4ca98694a6091fd8519f') in ['MESSAGE=test', 'MESSAGE_ID=8441372f-8dca-4ca9-8694-a6091fd8519f', 'CODE_FILE=testpath', 'CODE_LINE=1', 'name=test-logger', 'exc_info=None', ...]
E + where '8441372f8dca4ca98694a6091fd8519f' = UUID('8441372f-8dca-4ca9-8694-a6091fd8519f').hex
systemd/test/test_journal.py:116: AssertionError
______________________________ test_journalhandler_message_id_on_message _______________________________
def test_journalhandler_message_id_on_message():
record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None)
record.__dict__['MESSAGE_ID'] = TEST_MID2
sender = MockSender()
handler = journal.JournalHandler(logging.INFO, sender_function=sender.send,
MESSAGE_ID=TEST_MID)
handler.emit(record)
assert len(sender.buf) == 1
> assert 'MESSAGE_ID=' + TEST_MID2.hex in sender.buf[0]
E assert ('MESSAGE_ID=' + '8441370000000000000000001fd85000') in ['MESSAGE=test', 'MESSAGE_ID=84413700-0000-0000-0000-00001fd85000', 'CODE_FILE=testpath', 'CODE_LINE=1', 'name=test-logger', 'exc_info=None', ...]
E + where '8441370000000000000000001fd85000' = UUID('84413700-0000-0000-0000-00001fd85000').hex
systemd/test/test_journal.py:135: AssertionError
============================ 2 failed, 53 passed, 6 skipped in 0.16 seconds ============================
|
|
|
|
|
|
| |
Removed mid variable from JournalHandler since the MESSAGE_ID is already
in the extras variable. MESSAGE_ID was being set to None, but this won't
appear in the logs.
|
|
|
|
|
|
|
| |
Let's not try to make it look like a journal field. It should
be a normal parameter.
Followup for dce0a855c3281e7051b1cbe0f73386d1c90ef320.
|
|
|
|
|
| |
As with other functions, the wrapper is always present, but returns
OSError: [Errno 38] Function not implemented.
|
|
|
|
| |
Backwards compatibility for mapPriority is retained.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
This way we can skip ENOENT (which happens in containers).
While at it, let's extend the tests a bit, so that we at least
call all functions and check the type of the return value.
Also, drop '.nspawn' from the machine name, nspawn doesn't
use that suffix any more.
|
|
|
|
| |
Make _make_line concatenate only strings directly.
|
|\
| |
| | |
daemon: add basic support for sd_is_socket_sockaddr
|
| | |
|