Structlog processor to send logs to journald
Project description
structlog-journald
Structlog processor to send logs to journald.
Installation
To install structlog-journald, run:
pip install structlog-journald
You also need to install one of the journald binding implementations:
- CPython-based
systemd-python. - Cython-based
cysystemd.
Usage
Add the structlog_journald.JournaldProcessor to your list of structlog processors.
Before it, you should add the CallsiteParameterAdder.
import logging
import structlog
from structlog_journald import JournaldProcessor
structlog.configure(
processors=[
structlog.contextvars.merge_contextvars,
structlog.processors.add_log_level,
structlog.processors.CallsiteParameterAdder(),
structlog.processors.StackInfoRenderer(),
structlog.dev.set_exc_info,
structlog.processors.TimeStamper(fmt='%Y-%m-%d %H:%M:%S', utc=False),
structlog.processors.EventRenamer('message'),
JournaldProcessor(),
structlog.dev.ConsoleRenderer(),
],
wrapper_class=structlog.make_filtering_bound_logger(logging.NOTSET),
context_class=dict,
logger_factory=structlog.PrintLoggerFactory(),
cache_logger_on_first_use=False,
)
log = structlog.stdlib.get_logger()
log.info('Hello, world!')
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 structlog_journald-0.1.0.tar.gz.
File metadata
- Download URL: structlog_journald-0.1.0.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb8c2e7bdc97276c86eed72f2ebbc9f73bed3d6cf1348a80b7d7c9196cfec677
|
|
| MD5 |
8a47e970667472c94e5bdf18692c0463
|
|
| BLAKE2b-256 |
75bc4e47076ecd35b6a01b79d03292b5674c5de35dc44a95547fae789dec434e
|
File details
Details for the file structlog_journald-0.1.0-py3-none-any.whl.
File metadata
- Download URL: structlog_journald-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81eb48e3554b7a32dac78ad4155b0377e1cca77044482d230b8a2bdded1f2c93
|
|
| MD5 |
06aa22a2750091a61125da07cbf6325d
|
|
| BLAKE2b-256 |
6bfe39227622ed2d17f649c21d38239dbf19acdc2ab936ed20050f9b74be9a2f
|