Skip to main content

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

release lic 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.
# By default it attaches systemd logging handler to a root Python logger.
init_systemd_logging()  # Returns True if initialization went fine.

# 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/

Debug runs

  1. Run your script with:

$ sudo systemd-run -u debugme -t /usr/bin/python /home/my/testme.py
  1. Watch its journal with:

$ journalctl -u debugme -f -o verbose

Download files

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

Source Distribution

systemd-logging-1.0.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

systemd_logging-1.0.1-py2.py3-none-any.whl (6.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file systemd-logging-1.0.1.tar.gz.

File metadata

  • Download URL: systemd-logging-1.0.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for systemd-logging-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a26f70dbe03658d7a90d2d041db12a6b1ad7f41a6fd2f0fb357a989054ae2468
MD5 1a20440ca8e448a591ed26fa956e21a7
BLAKE2b-256 65f4f427364cc600d86f30f0eade19d912a7d580737a7f104672ce8dae27344b

See more details on using hashes here.

File details

Details for the file systemd_logging-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for systemd_logging-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 991eca9247691680ad5dd61da34b10f2b58441b26c043fc76186cad69c634030
MD5 d0e5460ce9402dc5eb2449b7556faaf1
BLAKE2b-256 e52ffba98c6a6aa57efa9ae47582634888fb5f0aa7d8faf016f829e69ed6f16f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page