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-bitmessage 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
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 logging_journald-0.6.11.tar.gz.
File metadata
- Download URL: logging_journald-0.6.11.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1741ae42cf8953e435489a82acf0e88bc21ad23351e867ca4453a354fc6d09e1
|
|
| MD5 |
674cf5b49a7b0804008c743032a3b4a5
|
|
| BLAKE2b-256 |
cc0777567e0001d3acffddc80470497f0eec3ccb544b72e672550b3c1f02e586
|
File details
Details for the file logging_journald-0.6.11-py3-none-any.whl.
File metadata
- Download URL: logging_journald-0.6.11-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d280eb0bddb4bf616297ee2428592b037618b6f0169c873f655aff92496c232
|
|
| MD5 |
18b88a5b0bae27af04e7ccb197c17dfa
|
|
| BLAKE2b-256 |
277b033a15aea43108af5049d8c0a09c3ea30519295aee1f3ed74c9efa1ee4cb
|