Dead simple loguru setup
Project description
loguru-kit
Safe & extensible loguru setup with conflict-free isolation.
Language: 한국어 | English
Installation
pip install loguru-kit
Quick Start
from loguru_kit import setup, get_logger
setup()
logger = get_logger(__name__)
logger.info("Hello, world!")
Features
- Conflict-free: No
logger.remove()- safe to use alongside other loguru users - Isolated loggers: Each module gets its own context via
logger.bind() - Async-safe: contextvars-based context propagation
- Simplified API: One-line setup for common use cases (JSON, File, OTEL)
- Integrations: FastAPI middleware, OpenTelemetry, stdlib intercept
Configuration
Parameters for setup()
| Parameter | Type | Default | Description |
|---|---|---|---|
level |
str |
"INFO" |
Log level |
json |
bool |
False |
Enable JSON output |
truncate |
int |
10000 |
Max message length |
file |
str | None |
None |
File path for file logging |
rotation |
str | int | None |
None |
File rotation (e.g., "10 MB", "1 day") |
retention |
str | int | None |
None |
File retention (e.g., "7 days") |
intercept |
list[str] | None |
None |
stdlib loggers to intercept |
otel |
bool |
False |
Enable OpenTelemetry trace injection |
force |
bool |
False |
Force reconfiguration |
Environment Variables
| Variable | Default | Description |
|---|---|---|
LOGURU_KIT_LEVEL |
INFO |
Log level |
LOGURU_KIT_JSON |
false |
JSON output |
Priority: code > env > defaults
File Logging
from loguru_kit import setup
setup(
file="logs/app.log",
rotation="10 MB",
retention="7 days"
)
FastAPI Integration
pip install loguru-kit[fastapi]
from fastapi import FastAPI
from loguru_kit import setup, get_logger
from loguru_kit.integrations.fastapi import LoggingMiddleware
setup()
app = FastAPI()
app.add_middleware(LoggingMiddleware, exclude_paths=["/healthz"])
logger = get_logger(__name__)
@app.get("/")
async def root():
logger.info("Request received")
return {"status": "ok"}
OpenTelemetry
pip install loguru-kit[otel]
from loguru_kit import setup, get_logger
# Enable OTEL trace injection
setup(otel=True)
logger = get_logger(__name__)
logger.info("This log will have trace_id and span_id")
stdlib Intercept
from loguru_kit import setup
# Intercept specific stdlib loggers
setup(intercept=["uvicorn", "sqlalchemy"])
License
MIT License - See LICENSE for details.
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
loguru_kit-0.7.0.tar.gz
(44.8 kB
view details)
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 loguru_kit-0.7.0.tar.gz.
File metadata
- Download URL: loguru_kit-0.7.0.tar.gz
- Upload date:
- Size: 44.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee8a77308dc5a1d8b603b0ea4cff906182e2b451e4090890bcb5f8cc5dfcd197
|
|
| MD5 |
edbce24d801761ea5cad9f50979f1755
|
|
| BLAKE2b-256 |
9a7d9a303c0cc665464b11db1636b93e6d274a2374054e547cc135995f292701
|
File details
Details for the file loguru_kit-0.7.0-py3-none-any.whl.
File metadata
- Download URL: loguru_kit-0.7.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a97bfd6d88956120c4f69c7e4f5c17a17c9cbe09d41a96fad170068bd28b1e5f
|
|
| MD5 |
fcb760cd969207ffde2b01fdb73c61a4
|
|
| BLAKE2b-256 |
9c03e9205cc015ba0a53a3f838d97e92d121ad6bb3c5ce9bf1ca5ff982d7ef8e
|