Pure python logging handler for writing logs to the journald using native protocol
Project description
logging-journald
Pure python logging handler for writing logs to the journald using native protocol.
import logging
from logging_journald import JournaldLogHandler, check_journal_stream
# Use python default handler
LOG_HANDLERS = None
if (
# Check if program running as systemd service
check_journal_stream() or
# Check if journald socket is available
JournaldLogHandler.SOCKET_PATH.exists()
):
LOG_HANDLERS = [JournaldLogHandler()]
logging.basicConfig(level=logging.INFO, handlers=LOG_HANDLERS)
logging.info("Hello logging world.")
MESSAGE_ID
field
As defined in catalog documentation:
A
128-bit
message identifier ID for recognizing certain message types, if this is desirable. This should contain a 128-bit ID formatted as a lower-case hexadecimal string, without any separating dashes or suchlike. This is recommended to be a UUID-compatible ID, but this is not enforced, and formatted differently. Developers can generate a new ID for this purpose with systemd-id128 new.
So you're free to choose how you want to act. By default, MESSAGE_ID
is generated as a hash of the message and some
static fields. But you can disable this by passing use_message_id=False
to the class constructor.
from logging_journald import JournaldLogHandler
...
handler = JournaldLogHandler(use_message_id=False)
...
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file logging_journald-0.6.7.tar.gz
.
File metadata
- Download URL: logging_journald-0.6.7.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.2 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fdb576fff2ff82e98be1c7b4f0cbd87f061de5dbed38030f388dd4ba2d52e7d |
|
MD5 | aec992b0a492cd46d2749e8d3c6c1fdb |
|
BLAKE2b-256 | e89edaf492d01cc4c7f5cb20abc4d0b16fd3f252afaec6a56ddd1896dae3694d |
File details
Details for the file logging_journald-0.6.7-py3-none-any.whl
.
File metadata
- Download URL: logging_journald-0.6.7-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.2 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef9333a84fd64fbe1e18ca6f22624af4fc5d92d519a2e2652aa43358548898eb |
|
MD5 | b1924a14750c7921a1bb460a08d66216 |
|
BLAKE2b-256 | 0cc7b3a10939808b5cfefa22e43edf1b86d8e388f01c31f297c16fa28738ac85 |