Skip to main content

Simplifies logging for systemd

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for systemd-logging, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size systemd_logging-0.2.0-py2.py3-none-any.whl (6.1 kB) File type Wheel Python version 2.7 Upload date Hashes View hashes
Filename, size systemd-logging-0.2.0.tar.gz (11.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page