Metadata-Version: 2.4
Name: molcrafts-mollog
Version: 1.2.0
Summary: Structured logging library for the molcrafts ecosystem
Author: Roy Kid
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://github.com/MolCrafts/mollog
Project-URL: Documentation, https://github.com/MolCrafts/mollog/tree/master/docs
Project-URL: Repository, https://github.com/MolCrafts/mollog
Project-URL: Issues, https://github.com/MolCrafts/mollog/issues
Project-URL: Changelog, https://github.com/MolCrafts/mollog/blob/master/CHANGELOG.md
Keywords: logging,structured-logging,python,json,molcrafts
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Logging
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rich>=13
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: ruff>=0.11; extra == "dev"
Requires-Dist: logfire>=3; extra == "dev"
Provides-Extra: docs
Requires-Dist: zensical>=0.0.32; extra == "docs"
Provides-Extra: logfire
Requires-Dist: logfire>=3; extra == "logfire"
Dynamic: license-file

# mollog

[![CI](https://github.com/MolCrafts/mollog/actions/workflows/ci.yml/badge.svg)](https://github.com/MolCrafts/mollog/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/molcrafts-mollog.svg)](https://pypi.org/project/molcrafts-mollog/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Python](https://img.shields.io/badge/python-3.12%2B-3776AB.svg?logo=python&logoColor=white)](./pyproject.toml)
[![License](https://img.shields.io/badge/license-BSD--3--Clause-16A34A.svg)](./LICENSE)

Structured logging for Python with a stdlib-compatible API — no `import logging` required.

## Quick Start

```python
import mollog

mollog.configure(
    level="INFO",
    format="%(asctime)s %(levelname)s %(name)s %(message)s",
)
mollog.get_logger("httpx").set_level("WARNING")  # silence noisy library

mollog.info("service booted", port=8080)
```

`mollog.configure(...)` accepts the same `format=` strings as `logging.basicConfig`, and by default installs a bridge so records emitted by libraries that still use stdlib `logging` (httpx, urllib3, openai, …) flow through mollog's hierarchy. Disable with `capture_stdlib=False`.

```bash
pip install molcrafts-mollog
# with optional logfire backend
pip install "molcrafts-mollog[logfire]"
```

## Features

- Drop-in for `logging.basicConfig`: stdlib-style `format=` strings and stdlib bridge
- Top-level helpers: `mollog.{trace, debug, info, warning, error, critical, exception}`
- Per-logger level control: `mollog.get_logger("httpx").set_level("WARNING")` (propagates to stdlib)
- Named loggers with hierarchy and propagation
- Structured `extra` fields and `Logger.bind()` for reusable context
- Context-local fields via the `Context` namespace (`Context.scope(...)` doubles as a logfire span)
- Exception and stack capture on every record
- `TextFormatter`, `JSONFormatter`, `RichFormatter`, and stdlib-style `StdlibStyleFormatter`
- `StreamHandler`, `FileHandler`, `RotatingFileHandler`, `TimedRotatingFileHandler`, `QueueHandler`
- Optional `LogfireHandler` + `configure_logfire()` for [Pydantic Logfire](https://logfire.pydantic.dev) backends
- `configure()` and `shutdown()` for application lifecycle

---

Built with love by [MolCrafts](https://github.com/MolCrafts)
