macwinnie-enhanced-logging: Batteries-included logging for Python applications. · Pythie
macwinnie-enhanced-logging
Last built version: v0.1.3
Batteries-included logging for Python applications.
macwinnie-enhanced-logging provides a clean, consistent logging setup built on top of:
Python’s built-in logging module (so third-party libraries keep working normally)
structlog (so your logs are structured, predictable, and easy to analyze)
It supports both developer-friendly console logs and structured JSON logs suitable for production environments like Kubernetes.
Further info: see GitHub Repo and Online-Documentation .
Features
Works with standard Python logging
Structured logging with structlog
Human-friendly console output for development
JSON output for log pipelines and observability stacks
Optional callsite information (file/function/line)
Built-in context variables (request_id, job_id, etc.)
Optional speaking logs for critical events
Zero boilerplate for most applications
Installation
pip install macwinnie-enhanced-logging
Requires Python 3.12+ .
Quick Start
1. Configure logging once in your application entry point
from enhanced_logging import configure_logging, get_logger
configure_logging()
log = get_logger(__name__)
log.info("startup", _fmt="Starting {app}…", app="demo")
2. Use the logger anywhere in your code
from enhanced_logging import get_logger
log = get_logger(__name__)
log.info("something_happened", user_id=123)
Output Formats
Two output formats are supported.
Human format (default)
Developer-friendly console output:
2025-01-01T10:00:00Z [info] Starting api on 127.0.0.1:8080 component=api host=127.0.0.1 port=8080
JSON format Machine-friendly structured output:
{
"timestamp": "2025-01-01T10:00:00Z",
"level": "info",
"event": "startup",
"msg": "Starting api on 127.0.0.1:8080",
"component": "api",
"host": "127.0.0.1",
"port": 8080
}
Switch formats using an environment variable:
_fmt: Human-Readable Messages with Structured LogsYou can provide _fmt to generate a human-readable message while still keeping structured fields.
log.info(
"startup",
_fmt="Starting {component} on {host}:{port}",
component="api",
host="127.0.0.1",
port=8080,
)
human format → replaces the event message
json format → keeps event and adds msg
This allows you to combine structured logging with readable messages .
Context Variables You can attach fields to all logs within a scope using log_context.
from enhanced_logging import get_logger, log_context
log = get_logger(__name__)
with log_context(request_id="req-123", user_id=42):
log.info("handling_request")
do_work()
log.info("done")
All logs inside the block will automatically include:
request_id=req-123 user_id=42
request IDs
job IDs
tenant identifiers
correlation IDs
Environment Variables Configuration is primarily done through environment variables.
Variable Description Default LOG_FORMAThuman or jsonhumanLOG_LEVELLogging level INFOLOG_UTCUse UTC timestamps 1LOG_KEEP_HANDLERSKeep existing root handlers 0LOG_CALLSITEauto, 1, or 0autoLOG_APP_NAMEOptional application name unset LOG_SPEAKEnable spoken logs 0LOG_SPEAK_LEVELMinimum level to speak ERRORLOG_SPEAK_CMDCustom speech command auto
Callsite Information
filename
function name
line number
Automatically enabled when LOG_LEVEL=DEBUG
Can be forced via:
Speaking Logs (Optional) macwinnie-enhanced-logging can optionally speak important log messages aloud .
CI pipelines
long-running batch jobs
alerting during development
Only errors and above are spoken by default.
Platform Engine macOS sayLinux espeakWindows PowerShell SAPI
If no speech engine is available, speaking is silently disabled.
You can also call the helper directly:
from enhanced_logging import speak
speak("Deployment finished successfully")
Configuration Example from enhanced_logging import configure_logging, LogConfig
configure_logging(
LogConfig(
format="json",
level="INFO",
app_name="my-service"
)
)
Integration with Third-Party Libraries Because macwinnie-enhanced-logging configures the root logger , libraries that use:
will automatically emit logs through the same handler.
one logging configuration for your entire application
consistent formatting across libraries
Best Practices
Call configure_logging() once at application startup
Use get_logger(__name__) in each module
Prefer structured fields over string concatenation
Use _fmt when you want readable console output
log.info(
"user_login",
_fmt="User {user_id} logged in",
user_id=123
)
Acknowledgements which provide the foundation for structured logging in Python.
Popularity
Downloads, last 7 days 2.2K-5%
Stars, last 7 days –
Direct dependents 0
All dependents 0 45
Fair
Maintenance, out of 100
Recent release
last release 267 days ago
Commit activity
0/26 weeks with commits
Release cadence
3 releases in 12 months
Issues & PRs handled
no data
Contributor spread
2 authors in last 100 commits
OpenSSF Scorecard
not evaluated
Releases
Latest 0.1.3
Released Mar 6, 2026
Releases, 12 months 3
First release Mar 4, 2026 Compatibility
Requires Python >=3.12
License unknown (Unknown) AlternativesUse instead of macwinnie-enhanced-logging: tools that do the same job, closest first.
Compare with loguru → Compare with lib-log-rich → Compare with structlog-config → Compare all 4 →
loguru 0.8.0 Active Pythie’s Index: 69Python logging made (stupidly) simple
Rich-powered logging runtime with contextual metadata, multi-sink fan-out, and ring-buffer dumps
A comprehensive structlog configuration with sensible defaults for development and production environments, featuring context management, exception formatting, and path prettification.
mo-logs 8.703.26061 Maintained Pythie’s Index: 36More Logs! Structured Logging and Exception Handling
Logging & Observability 3 116.4K/moReleased Mar 2, 2026 Minimalistic wrapper for Python logging.
Logging & Observability 31 184.4K/moReleased Oct 15, 2026 Library to configure Python logging easily
Logging & Observability 342 391.1K/moReleased Sep 4, 2025 Works well withUse together with macwinnie-enhanced-logging: extensions, drivers, servers and companion tools.
structlog-sentry Pythie’s Index: 51Sentry integration for structlog 4.7M downloads/mo