Zero-dependency structured logging library for the molcrafts ecosystem
Project description
mollog
mollog is a typed, dependency-free structured logging library for Python applications that want clear output, small surface area, and explicit control.
Version 1.0.0 focuses on the pieces needed in real projects: hierarchical loggers, structured context, JSON/text formatting, queue-based fan-out, optional Rich console output, and predictable shutdown/configuration hooks.
Highlights
- Zero required runtime dependencies
- Typed public API with
py.typed configure()andshutdown()helpers for application setup- Structured
extra,bind(), and context-local fields viabind_context()/scoped_context() - Text, JSON, file, rotating-file, timed-rotating, queue, and Rich handlers
- Exception and stack capture built into the record model
Installation
Core package:
pip install molcrafts-mollog
Development environment:
pip install -e ".[dev,docs,rich]"
Rich terminal support:
pip install "molcrafts-mollog[rich]"
Quickstart
from mollog import JSONFormatter, StreamHandler, configure, get_logger
handler = StreamHandler()
handler.set_formatter(JSONFormatter())
configure(level="info", handlers=[handler])
logger = get_logger("api")
logger.info("request complete", status=200, duration_ms=18)
Contextual logging
from mollog import bind_context, get_logger, scoped_context
logger = get_logger("worker")
with scoped_context(request_id="req-42", trace_id="trace-7"):
logger.bind(component="ingest").info("started")
token = bind_context(batch="nightly")
try:
logger.info("continuing")
finally:
from mollog import reset_context
reset_context(token)
Exception logging
from mollog import get_logger
logger = get_logger("api")
try:
raise ValueError("bad payload")
except ValueError:
logger.exception("request failed", request_id="req-17")
Rich console output
from mollog import RichHandler, configure, get_logger
configure(handlers=[RichHandler()], level="debug")
logger = get_logger("cli")
logger.warning("unexpected value", field="charge", observed="2+")
Release-ready API surface
Core exports include:
get_logger()configure()shutdown()bind_context()scoped_context()clear_context()Logger,BoundLogger,LoggerManagerTextFormatter,JSONFormatterStreamHandler,FileHandler,RotatingFileHandler,TimedRotatingFileHandler,QueueHandlerRichHandlerwithmolcrafts-mollog[rich]
Documentation
The repository includes a Zensical documentation site.
uv run zensical serve
Build the static site:
uv run zensical build
Main pages:
- Getting Started
- Configuration
- Context Propagation
- Behavior Notes
- Rich Console Logging
- API Reference
- Release Notes
Development
pip install ".[dev]"
pytest -q
See CONTRIBUTING.md for contribution workflow and RELEASING.md for the 1.x release process.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file molcrafts_mollog-1.0.0.tar.gz.
File metadata
- Download URL: molcrafts_mollog-1.0.0.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f434bea996dd37e58123342a68c3f9ac9e5170f8f25c990bc4fa4b8f81f7008b
|
|
| MD5 |
e2b50465818497a5e7e872330563024f
|
|
| BLAKE2b-256 |
e57ff1d779d1bae794944bfd3926b841605595c6ae3e0c759557cacd72ecdb23
|
Provenance
The following attestation bundles were made for molcrafts_mollog-1.0.0.tar.gz:
Publisher:
release.yml on MolCrafts/mollog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molcrafts_mollog-1.0.0.tar.gz -
Subject digest:
f434bea996dd37e58123342a68c3f9ac9e5170f8f25c990bc4fa4b8f81f7008b - Sigstore transparency entry: 1280214005
- Sigstore integration time:
-
Permalink:
MolCrafts/mollog@7d8215fe79b3656b07278d900e20b2289d59ee00 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/MolCrafts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7d8215fe79b3656b07278d900e20b2289d59ee00 -
Trigger Event:
push
-
Statement type:
File details
Details for the file molcrafts_mollog-1.0.0-py3-none-any.whl.
File metadata
- Download URL: molcrafts_mollog-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bf8d3aafef0bbf3df1b67f0fb8a243aa9ce51926f4fd4c080f86c03ab24973e
|
|
| MD5 |
46d71211a93ed88acb90efdc8ebc7d36
|
|
| BLAKE2b-256 |
a8b562304f457549c417df0a97017980ada61fedc22eeefd85166ef8efedfb3e
|
Provenance
The following attestation bundles were made for molcrafts_mollog-1.0.0-py3-none-any.whl:
Publisher:
release.yml on MolCrafts/mollog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
molcrafts_mollog-1.0.0-py3-none-any.whl -
Subject digest:
4bf8d3aafef0bbf3df1b67f0fb8a243aa9ce51926f4fd4c080f86c03ab24973e - Sigstore transparency entry: 1280214006
- Sigstore integration time:
-
Permalink:
MolCrafts/mollog@7d8215fe79b3656b07278d900e20b2289d59ee00 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/MolCrafts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7d8215fe79b3656b07278d900e20b2289d59ee00 -
Trigger Event:
push
-
Statement type: