stogger Documentation¶
A sophisticated multi-target structured logging system built on structlog
A structured logging library built on structlog with console, systemd journal, and PostgreSQL targets, plus AST-based convention checking via pytest-stogger.
Quick Start¶
Install stogger and start logging:
uv add stogger
import stogger
import structlog
# Initialize console logging and get a structlog logger
stogger.init_logging(verbose=True)
log = structlog.get_logger()
log.info("hello-world", user_id=123, action="login")
Key Features¶
Multi-Target Output — Simultaneous console (colorized), file, systemd journal, and PostgreSQL targets via
MultiRendererLogging Decorators —
@log_call,@log_result,@log_operationdecorators andlog_scope()context manager with sync/async supportMessage Translation — TOML-based i18n with
_replace_msgpattern for human-readable formatted log messagesFlexible Timestamps — Configurable precision:
iso,iso_seconds,iso_no_z, orrelative(process-elapsed)AST Convention Checking — pytest-stogger enforces 13 logging rules (except-must-log, no-info-in-except, etc.) at test time
JSON Output — Switch to structured JSON with
log_format="json"in[tool.stogger]
User Guide¶
API Reference¶
API Reference