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.1.tar.gz
(5.7 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.1.tar.gz.
File metadata
- Download URL: kitstructlog-0.1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a4fbb34e216671a9a1aceb66b8512f86510c236fda66d9a0aa8f9e929036d85
|
|
| MD5 |
a889110344e88138611c9d05834ca079
|
|
| BLAKE2b-256 |
77ccf8134d5b8e4e7d30df3e5a388393f7995264612ff62057892b222b6b275d
|
File details
Details for the file kitstructlog-0.1.1-py3-none-any.whl.
File metadata
- Download URL: kitstructlog-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.6 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 |
099489f31199a88f699e706c502f9e1031224655ac765f625842e576ae31e6f4
|
|
| MD5 |
6a7f1921d25b1c400416e1159c467032
|
|
| BLAKE2b-256 |
3c854fe69384e59bdee4f490878e327e42e458f862fb9faf58eb884238aaafa0
|