Simplifies logging for systemd
Project description
https://github.com/idlesign/systemd-logging
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
Run your script with:
$ sudo systemd-run -u debugme -t /usr/bin/python /home/my/testme.py
Watch its journal with:
$ journalctl -u debugme -f -o verbose
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a26f70dbe03658d7a90d2d041db12a6b1ad7f41a6fd2f0fb357a989054ae2468
|
|
| MD5 |
1a20440ca8e448a591ed26fa956e21a7
|
|
| BLAKE2b-256 |
65f4f427364cc600d86f30f0eade19d912a7d580737a7f104672ce8dae27344b
|
File details
Details for the file systemd_logging-1.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: systemd_logging-1.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/2.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
991eca9247691680ad5dd61da34b10f2b58441b26c043fc76186cad69c634030
|
|
| MD5 |
d0e5460ce9402dc5eb2449b7556faaf1
|
|
| BLAKE2b-256 |
e52ffba98c6a6aa57efa9ae47582634888fb5f0aa7d8faf016f829e69ed6f16f
|