Skip to main content

kitstructlog

PyPI version Python Versions License: MIT

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.

Metadata

Release files for kitstructlog 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kitstructlog 0.1.2
File Size Uploaded
kitstructlog-0.1.2.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kitstructlog 0.1.2
File Interpreter ABI Platform
kitstructlog-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / kitstructlog-0.1.2.tar.gz

Download URL kitstructlog-0.1.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c5e5395a05eaeba2481d8e7bc3ae4c1554051e561945ca4397f47273aee417f0
BLAKE2b-256 checksum
How to use checksums
e90a146b5791553e617291ef65f24f1afe3cda20f56391ce0ce945ac28edeaa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / kitstructlog-0.1.2-py3-none-any.whl

Download URL kitstructlog-0.1.2-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1b3b8d360011413162b64bc787c8f108d5c99bc4940e3ef4c7e0d7e253815a2
BLAKE2b-256 checksum
How to use checksums
3ef970f6360e3a8c109615ae8498b76da52e15a325d4bad4d6208ccf7024b9a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page