| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| | |
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
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 ============================
|
| |
|
|
|
|
|
| |
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.
|
| |\
| |
| | |
daemon: add basic support for sd_is_socket_sockaddr
|
| | | |
|
| | |
| |
| |
| | |
Specifying the address without does not work.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
When running in a chroot, doctests that called journal.stream would
fail with ENOENT. Move the tests to test_journal, where we can skip
tests properly (without uglyfying the documentation).
Fixes #32.
|
| | |
| |
| | |
py3 doesn't have dict.iteritems() anymore.
|
| |/
|
|
|
| |
This bind() call may fail if TMPDIR is too long.
Bug: https://bugs.gentoo.org/610368
|
| | |
|
| |
|
|
| |
Should fix #12.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This somewhat breaks backwards compatibility, but not for the
previously documented arguments: floats are now interpreted
differently, but ints and datetime.datetime objects are interpreted
the same as before. But the documentation clearly stated that only
ints and datetime.datetime objects were allowed.
This makes seek_realtime match seek_monotonic and other functions
which take time and follows the principle of least surprise.
Fixes #21.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Let's pass any flags through to the journal functions without checking
validity. Those functions do their own checking, so there's no need to
second-guess.
The semantics for _Reader(flags=0) are a bit changed:
before, this would be transformed into sd_journal_open(SD_J_LOCAL_ONLY).
Now, this results in sd_journal_open(0). Previous behaviour should be
achieved by not specifying the flags at all.
This change is necessary, because previously it was not possible to
pass flags=0 to sd_journal_open(0), i.e. it was not possible to "merge"
journals through the Python interface.
Similarly, Reader(flags=0) now means to open all journals, and
Reader(flags=None) is the same as Reader(flags=LOCAL_ONLY).
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
The socket module seems to be missing this in python2.7.
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
The fix was committed in v226-362-g0260d1d542.
|
| |
|
|
|
|
|
| |
It would be nice to run those tests against fake journal files
with the right content to actually test the matches. But those
tests are still useful because they test that the interface
works as expected.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|
|
This is based on the code in https://github.com/systemd/python-systemd/pull/4
by Jacek Konieczny <j.konieczny@eggsoft.pl>.
|