skillfed

mo-logs

More Logs! Structured Logging and Exception Handling

mo-logs v8.703.26061 117.8K downloads/30d#12,147 on PyPI3
Copyleft license MPL 2.0 Active released

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-logs

uv

uv add mo-logs

poetry

poetry add mo-logs

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

structured logging jsonexception handling loggingcontext-aware loggingparametric loggingexception chaining
structured-loggingexception-handlingjson-output

More Libraries packages