Skip to main content

systemd-logging

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

Metadata

Release files for systemd-logging 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for systemd-logging 1.0.1
File Size Uploaded
systemd-logging-1.0.1.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for systemd-logging 1.0.1
File Interpreter ABI Platform
systemd_logging-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 18.9 kB

Release files / systemd-logging-1.0.1.tar.gz

Download URL systemd-logging-1.0.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a26f70dbe03658d7a90d2d041db12a6b1ad7f41a6fd2f0fb357a989054ae2468
BLAKE2b-256 checksum
How to use checksums
65f4f427364cc600d86f30f0eade19d912a7d580737a7f104672ce8dae27344b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release files / systemd_logging-1.0.1-py2.py3-none-any.whl

Download URL systemd_logging-1.0.1-py2.py3-none-any.whl
Size 6.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
991eca9247691680ad5dd61da34b10f2b58441b26c043fc76186cad69c634030
BLAKE2b-256 checksum
How to use checksums
e52ffba98c6a6aa57efa9ae47582634888fb5f0aa7d8faf016f829e69ed6f16f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page