summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* journal: remove ChainMapmasterGlandos2020-11-121-11/+3
| | | | | | | "after some quick testing, the execution time got halved (32-ish seconds to 16-ish seconds) when going through all journal entries." Closes #63.
* journal: add namespace supportAlexander Olekhnovich2020-11-122-19/+41
| | | | Add log namespace support which is added since systemd v245
* journal: allow JournalHandler constructor to be called with args in a ↵Tamaki Nishino2020-11-122-0/+28
| | | | | | | | | | | | | | | 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.]
* test: make sure $NOTIFY_SOCKET is unset in testZbigniew Jędrzejewski-Szmek2020-11-121-0/+2
| | | | | | 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.
* reader: make PY_SSIZE_T_CLEANZbigniew Jędrzejewski-Szmek2020-11-121-2/+13
|
* journal: avoid warning about deprecated constantZbigniew Jędrzejewski-Szmek2020-11-121-1/+1
|
* Fix seek_realtime to work with timezone aware dateLéonard Gérard2020-11-121-1/+1
| | | | | `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()`.
* make: Move -std=99 to setup.pyDominik Prien2020-11-112-8/+6
|
* include endian.h for htobe16 definitionKhem Raj2020-11-111-0/+1
|
* Fix a typoHendrikto2020-11-111-1/+1
|
* docs: mention .process() in docstring of .fileno()Zbigniew Jędrzejewski-Szmek2019-06-161-2/+5
| | | | | Together with the previous commit, this makes it much easier to find the right docs. Fixes #48.
* docs: use :manpage: role to provide links to systemd man pagesZbigniew Jędrzejewski-Szmek2019-06-163-25/+26
| | | | | See https://github.com/sphinx-doc/sphinx/pull/4235 for the :manpage: role.
* make: fix "make doc" invocationsZbigniew Jędrzejewski-Szmek2019-06-161-2/+2
| | | | | | | | | | python insists on adding . to python.path, so we always import the systemd in the top-level directory instead of the one in build/ that we want. Let's cd into docs/ first, so that we get the right module imported. Also, replace sphinx-build calls with $(PYTHON) -m sphinx. This has the advantage that once $(PYTHON) is set, the appropriate sphinx executable is chosen.
* Document libsystemd compatiblityZbigniew Jędrzejewski-Szmek2019-06-161-0/+11
| | | | Closes #49.
* Use #if instead of #ifdef for compatibility checksZbigniew Jędrzejewski-Szmek2019-06-162-33/+23
| | | | | This has the advantage that it is slightly less verbose, and also any potential typos in the macro names are immediately detected.
* make: use -std=c99Zbigniew Jędrzejewski-Szmek2019-06-161-1/+3
| | | | | | | I see no good reason to support old standards, when systemd itself requires c99. Let's test with c99 in the CI. Closes #62.
* id128: update constants for systmed-243Zbigniew Jędrzejewski-Szmek2019-06-163-0/+21
|
* tests: add tests for all id128 funcs, including get_machine_app_specific()Zbigniew Jędrzejewski-Szmek2019-06-162-1/+48
|
* id128: conditionalize get_machine_app_specific on libsystemd versionZbigniew Jędrzejewski-Szmek2019-06-161-6/+14
|
* id128: do not copy the id128 buffer bytesZbigniew Jędrzejewski-Szmek2019-06-161-8/+5
| | | | | | There doesn't seem to be any particular need to do this. Also remove unused uuid variable.
* Add id128.get_machine_app_specific functionTomasz Meresiński2019-06-161-0/+39
|
* README: use some more <h2> tagsZbigniew Jędrzejewski-Szmek2019-06-161-1/+3
|
* Modernize C syntaxZbigniew Jędrzejewski-Szmek2019-06-165-41/+40
|
* _listen_fd_with_names documentation now modeled after is_socket_sockaddrMarcel Waldvogel2019-06-161-2/+5
|
* Added support for listen_fds_with_names()Marcel Waldvogel2019-06-164-3/+145
|
* tests: add the reproducer from #51Zbigniew Jędrzejewski-Szmek2019-06-161-0/+13
| | | | | | 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.
* Merge pull request #51 from feedstock/fix_notify_fs_leakZbigniew Jędrzejewski-Szmek2019-06-161-2/+2
|\ | | | | Fix notify fs leak
| * Fix malloc retval checkMarco Paolini2017-09-121-1/+1
| |
| * Avoid ref leak in notifyMarco Paolini2017-09-121-1/+1
| |
* | add JournalHandler usage in READMEytyt-yt2019-06-161-0/+8
| |
* | Adapt to systemd 230 tool renaming, bump versionMarcel Waldvogel2019-06-163-2/+7
|/
* README: also mention CentoOS and RHEL in instructionsZbigniew Jędrzejewski-Szmek2017-04-141-2/+2
| | | | | | | | The latest supported version of Fedora is now 24, and python3 is supported on all current versions, so drop references to old Fedora from the README. Fixes #47.
* Prepare v234v234Zbigniew Jędrzejewski-Szmek2017-03-252-1/+18
|
* Update to constants from systemd-233Zbigniew Jędrzejewski-Szmek2017-03-255-40/+54
| | | | | | | 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.
* journal: fix repr of JournalHandler to match python3.6Zbigniew Jędrzejewski-Szmek2017-03-251-1/+1
| | | | | | 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
* journal: do not convert extra args to string in JournalHandlerZbigniew Jędrzejewski-Szmek2017-03-192-6/+6
| | | | | | 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.
* test_journal: add tests for MESSAGE_ID passingZbigniew Jędrzejewski-Szmek2017-03-191-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ============================
* Remove mid from JournalHandlerWesley Bowman2017-03-191-2/+0
| | | | | | 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.
* journal: rename SENDER_FUNCTION to sender_functionZbigniew Jędrzejewski-Szmek2017-03-192-3/+6
| | | | | | | Let's not try to make it look like a journal field. It should be a normal parameter. Followup for dce0a855c3281e7051b1cbe0f73386d1c90ef320.
* daemon: properly skip sd_is_socket_sockaddr calls if not availableZbigniew Jędrzejewski-Szmek2017-03-192-19/+38
| | | | | As with other functions, the wrapper is always present, but returns OSError: [Errno 38] Function not implemented.
* Makefile: add convenience "shell" target to start python shellZbigniew Jędrzejewski-Szmek2017-03-191-1/+5
|
* Makefile: add "doc" target for convenienceZbigniew Jędrzejewski-Szmek2017-03-191-1/+3
|
* Makefile: remove unneeded -I/usr/include from flagsZbigniew Jędrzejewski-Szmek2017-03-191-1/+2
| | | | | | | gcc warns about an include directive that shadows the system include directory at high verbosity levels. Let's filter it out (pkgconfig implements that) to reduce noise and also to make the command line shorter.
* Fix styling to match PEP8 in most places (#45)Wesley Bowman2017-03-142-7/+20
| | | | Backwards compatibility for mapPriority is retained.
* Merge pull request #34 from keszybz/test-skippingZbigniew Jędrzejewski-Szmek2017-03-137-25/+77
|\ | | | | Improve test skipping on old systems.
| * journal: improve docstring formatting a bitZbigniew Jędrzejewski-Szmek2017-03-121-4/+4
| |
| * Adjust import order, spacing, operators as recommended by pylintZbigniew Jędrzejewski-Szmek2017-03-124-19/+21
| |
| * tests: move login tests from doctest to separate fileZbigniew Jędrzejewski-Szmek2017-03-123-4/+54
|/ | | | | | | | | 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.
* Prevent non-str values from being concatenated with + (#40)Jimmy Cao2017-03-121-3/+3
| | | | Make _make_line concatenate only strings directly.
* Merge pull request #31 from keszybz/is_socket_sockaddrZbigniew Jędrzejewski-Szmek2017-03-119-28/+366
|\ | | | | daemon: add basic support for sd_is_socket_sockaddr