Skip to content
Simplifies logging for systemd
Python
Branch: master
Clone or download
Latest commit fd9c1c8 Oct 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo Added simple demo Oct 15, 2019
docs Fature list extended. Oct 14, 2019
systemdlogging Release v0.2.0 Oct 15, 2019
tests Update test_module.py Oct 15, 2019
.coveragerc Start here. Oct 14, 2019
.gitignore
.hgignore Start here. Oct 14, 2019
.travis.yml Start here. Oct 14, 2019
AUTHORS Start here. Oct 14, 2019
CHANGELOG Release v0.2.0 Oct 15, 2019
CONTRIBUTING Start here. Oct 14, 2019
INSTALL Start here. Oct 14, 2019
LICENSE Start here. Oct 14, 2019
MANIFEST.in
README.rst
setup.cfg
setup.py
tox.ini Start here. Oct 14, 2019

README.rst

systemd-logging

https://github.com/idlesign/systemd-logging

release lic ci coverage

Description

Simplifies logging for systemd

Requires Python 3.6+

  • No need to compile (pure Python), uses libsystemd.so.
  • Simplified configuration.
  • Just logging. Nothing more.

Usage

import logging

from systemdlogging.toolbox import init_systemd_logging

# This one line in most cases would be enough.
init_systemd_logging()
# By default it attaches systemd logging handler to a root Python logger.

# Now you can use logging as usual.
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

logger.debug('My debug message')

try:
    raise ValueError('Log me please')

except ValueError:
    # Additional context can be passed in extra.context.
    logger.exception('Something terrible just happened', extra={
        'message_id': True,  # Generate message ID automatically.
        'context': {
            'FIELD1': 'one',
            'FIELD2': 'two',
        }
    }, stack_info=True)

Read the docs to find out more.

Documentation

https://systemd-logging.readthedocs.org/

You can’t perform that action at this time.