mo-logs
More Logs! Structured Logging and Exception Handling
What it is and what it does
mo-logs is a structured logging library that outputs all logs as JSON and tightly integrates exception handling into the logging flow. Instead of using Python's standard logging module, you import a single logger object and call methods like logger.info() or logger.error() with message templates and named parameters. The library automatically captures calling context (file, line, method, thread, machine details) without requiring you to create logger instances per module.
The key design principle is that exceptions and logging are inseparable: logger.error() raises an exception that can be caught by calling code, and only logs if it propagates uncaught. You chain exceptions using a cause parameter rather than raise-from syntax, and can test whether a specific exception message template exists anywhere in the causal chain using the in operator. All parameters are kept separate from the template string to preserve structure for downstream log analysis tools.
Use it for:
- Build microservices or distributed systems where structured JSON logs feed into centralized log aggregation and analysis tools.
- Debug complex call chains by attaching extra properties to all subsequent log messages, including those from spawned threads.
- Replace standard Python logging in existing codebases by changing import statements without rewriting exception handling logic.
- Log parametric data safely without risk of accidentally including sensitive local variables (the library discourages locals() usage).
- Identify root causes in exception chains without creating custom exception classes—exceptions are identified by their message templates.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides structured JSON logging with integrated exception handling that tracks calling context automatically, allowing you to log messages with named parameters and chain exceptions without creating custom exception types.
Yes, if you are building systems that require structured logging and want exception handling semantics tightly integrated with logging. The low install friction, active maintenance, and zero known vulnerabilities make it safe to adopt. The copyleft license is a minor constraint if you plan to keep the library proprietary, but acceptable for most open-source and internal projects. Not necessary if you are satisfied with standard Python logging or do not need JSON-structured output.
Install
mo-logs on PyPI
pip
pip install mo-logsuv
uv add mo-logspoetry
poetry add mo-logsInstalling mo-logs
Before you install
Low friction install with four lightweight runtime dependencies (mo-dots, mo-future, mo-imports, mo-kwargs). Active maintenance with recent commits and stable production status.
License in practice
Licensed under MPL 2.0 (copyleft). You must disclose source code modifications and can use it in proprietary software, but derivative works of the library itself must remain open-source.
Quickstart
from mo_logs import logger
logger.info("Hello, {name}!", name="World!")
try:
# code that might fail
except Exception as cause:
logger.error("Failed to process", cause=cause)
Verify before relying
- Whether the library's automatic context tracking (file, line, method, thread, machine info) has measurable performance impact in high-throughput scenarios.
- How well the JSON serialization handles circular references or non-standard Python objects in logged parameters.
Package facts
| License | MPL 2.0 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — mo-dots, mo-future, mo-imports, mo-kwargs |
| Maintenance | actively maintained — 165 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 117,824/month — #12,147 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mo_logs-8.703.26061-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
JSON-log-formatterFormats Python logging records as JSON,…
permissive · top 5,000 on PyPI
lib-log-richProvides Rich-styled colored console logging…
permissive · top 15,000 on PyPI
json-loggingConfigures Python's standard logging module to…
permissive · top 5,000 on PyPI
eliotEliot is a structured logging system that…
permissive · top 15,000 on PyPI
TwiggyTwiggy is a structured logging library that…
permissive · top 15,000 on PyPI
splunk-hec-handlerIntegrates Python logging with Splunk's HTTP…
permissive · top 15,000 on PyPI
django-log-formatter-asimFormats Django application logs in Azure…
permissive · top 15,000 on PyPI
logstash_formatterFormats Python logging output as JSON objects…
permissive · top 15,000 on PyPI
django-structlogIntegrates structured logging into Django…
permissive · top 5,000 on PyPI
python-json-loggerFormats Python logging output as JSON, making…
permissive · top 1,000 on PyPI