--- id: mo-logs version: "8.703.26061" license: MPL 2.0 license_treatment: copyleft maintenance: active --- # mo-logs — More Logs! Structured Logging and Exception Handling License: copyleft · Maintenance: active · Downloads: 117.8K/mo ## 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 above — 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 pip install mo-logs uv add mo-logs 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: unspecified - Install friction: low - Maintenance: active - Downloads: 117.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags structured logging json, exception handling logging, context-aware logging, parametric logging, exception chaining, structured-logging, exception-handling, json-output [View on SkillFed](https://skillfed.io/packages/mo-logs) · [View on PyPI](https://pypi.org/project/mo-logs/)