A superstructure over structlog that simplifies the configuration and use of structured logging in Python.
Project description
kitstructlog
A superstructure over structlog that simplifies the configuration and use of structured logging in Python.
✨ Features
- Simple declaration of project loggers via
dataclass-like syntax - Automatic setup of
logging+structlog - Developer-friendly console output or JSON structured logs (depending on mode)
- Extensible processors chain (timestamps, stack info, caller details, etc.)
- Support for multiple named loggers in one place
📦 Installation
pip install kitstructlog
🚀 Quick Start
Basic usage
import structlog
from kitstructlog import InitLoggers, LoggerReg
class Loggers(InitLoggers):
app = LoggerReg(name="APP", level=LoggerReg.Level.INFO)
db = LoggerReg(name="DATABASE", level=LoggerReg.Level.DEBUG)
# Initialize
loggers = Loggers(developer_mode=True)
# Use logger
logger = structlog.getLogger(Loggers.app.name)
logger.info("Application started", version="1.0.0")
JSON logging
import structlog
from kitstructlog import InitLoggers, LoggerReg
class Loggers(InitLoggers):
app = LoggerReg(name="APP", level=LoggerReg.Level.INFO)
access = LoggerReg(name="ACCESS", level=LoggerReg.Level.INFO)
# developer_mode=False => JSON output
loggers = Loggers(developer_mode=False)
logger = structlog.getLogger(Loggers.access.name)
logger.info("Request handled", status=200, path="/login")
Example JSON output:
{
"timestamp": "2025-09-21 03:09:46",
"level": "info",
"logger": "json_logging:logger:14",
"_msg": "Request handled",
"status": 200,
"path": "/login"
}
Multiple loggers
import structlog
from kitstructlog import InitLoggers, LoggerReg
class Loggers(InitLoggers):
auth = LoggerReg(name="AUTH", level=LoggerReg.Level.DEBUG)
router = LoggerReg(name="ROUTER", level=LoggerReg.Level.INFO)
utils = LoggerReg(name="UTILS", level=LoggerReg.Level.DEBUG)
loggers = Loggers(developer_mode=True)
auth_logger = structlog.getLogger(Loggers.auth.name)
auth_logger.debug("Checking token", token="abc123")
router_logger = structlog.getLogger(Loggers.router.name)
router_logger.info("New request", path="/api/v1/resource")
📜 License
MIT License — see LICENSE for details.
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
kitstructlog-0.1.2.tar.gz
(6.2 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 kitstructlog-0.1.2.tar.gz.
File metadata
- Download URL: kitstructlog-0.1.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5e5395a05eaeba2481d8e7bc3ae4c1554051e561945ca4397f47273aee417f0
|
|
| MD5 |
9b6f4c5523541fd4eaa434b238a862fb
|
|
| BLAKE2b-256 |
e90a146b5791553e617291ef65f24f1afe3cda20f56391ce0ce945ac28edeaa2
|
File details
Details for the file kitstructlog-0.1.2-py3-none-any.whl.
File metadata
- Download URL: kitstructlog-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1b3b8d360011413162b64bc787c8f108d5c99bc4940e3ef4c7e0d7e253815a2
|
|
| MD5 |
6dfada3808df9d15f50554f847a56692
|
|
| BLAKE2b-256 |
3ef970f6360e3a8c109615ae8498b76da52e15a325d4bad4d6208ccf7024b9a6
|