Unified Loguru logging helpers with standard logging interception and trace context support.
Project description
zcy-loguru
zcy-loguru provides a small wrapper around loguru for structured logging,
standard library logging interception, and trace/span propagation.
Install
pip install zcy-loguru
Install optional OpenTelemetry support with:
pip install "zcy-loguru[otel]"
Usage
from zcy_logger import init_logging, logger
init_logging()
logger.info("hello")
init_logging() replaces Loguru's default sink with the configured JSON (or
human-readable) sink and forwards standard-library logging records to it.
It can be called explicitly when an application needs custom options.
OpenTelemetry auto-instrumentation
Install the optional dependency and start the application through the standard OpenTelemetry launcher:
pip install "zcy-loguru[otel]"
opentelemetry-instrument python main.py
The ZcyLoguruInstrumentor entry point calls init_logging() before the
application is imported. Explicit init_logging(...) calls remain supported
for applications that need non-default output settings.
When a log record has an active OpenTelemetry span, its trace and span IDs are
included in the output. Without one, zcy-loguru creates and ends a root
zcy.log span for that record. If no usable OpenTelemetry provider is
configured, it generates local IDs instead, so trace_id and span_id are
always present. Creating one root span per uncorrelated log record can increase
trace volume substantially.
Taking over legacy loggers
Applications with named standard-library loggers that install private handlers
or set propagate = False can explicitly route them through zcy-loguru:
from zcy_logger import init_logging, intercept_loggers
init_logging()
intercept_loggers("seal_agent.log", "err.log")
Call intercept_loggers() before legacy logger setup when possible. It replaces
the named logger's handlers with the zcy-loguru bridge, preventing duplicate
output even if the legacy setup disables propagation.
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 zcy_loguru-0.3.1.tar.gz.
File metadata
- Download URL: zcy_loguru-0.3.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
130eb41c9e827bf1ac67cbd679661e331fa988b92c89786c42a614118b079096
|
|
| MD5 |
fa91fc1a91825d30857a74e9da4929c1
|
|
| BLAKE2b-256 |
817e30a8ca1bbcc8dcba22ec3a1f1d5a4ce8f094d34a9d2372fcd5f95d2eea8d
|
File details
Details for the file zcy_loguru-0.3.1-py3-none-any.whl.
File metadata
- Download URL: zcy_loguru-0.3.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
990fbbc434f89e82aa7fdcb0ede3dab4f4a0f329df494204a156b04735a958e0
|
|
| MD5 |
ecb0c1ad0d34e9402f1fec719906b4b2
|
|
| BLAKE2b-256 |
70eaf34ff4243b48ee45ebe1cd9da17ab5a316056f042e5f384a3d9d97b2e426
|