mollog
Structured logging for Python with a stdlib-compatible API — no import logging required.
mollog is a structured logging library for Python that mirrors the standard library's logging API while adding structured extra fields, JSON output, context propagation, and a bridge that funnels stdlib records into its own hierarchy. Migrate from logging.basicConfig without changing your format strings.
Capabilities
| Module | Capability |
|---|---|
_manager |
Singleton logger registry plus the top-level API: configure / basicConfig, get_logger / getLogger, set_level, shutdown, and trace/debug/info/warning/error/critical/exception helpers |
_logger |
Named Logger with hierarchy, propagation, per-logger levels, bind() for reusable context, and exception/stack capture |
_record |
Immutable frozen LogRecord dataclass — level, message, logger name, timestamp, extra, exception, stack info |
_level |
Level enum — TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL — with coercion from ints, names, or enum values |
_context |
Context namespace — thread- and asyncio-safe context fields via contextvars; Context.scope() doubles as a logfire span |
_handler |
Handler base class plus StreamHandler and NullHandler |
_file_handler |
FileHandler, RotatingFileHandler, and TimedRotatingFileHandler |
_queue |
QueueHandler and background-thread QueueListener for thread/process-safe logging |
_formatter |
Formatter base plus TextFormatter, JSONFormatter, and stdlib-style StdlibStyleFormatter |
_rich |
RichFormatter — ANSI-styled, color-coded output via rich |
_filter |
Filter base class and LevelFilter for level-range filtering |
_stdlib_bridge |
StdlibBridgeHandler plus capture_stdlib_logging / release_stdlib_logging — routes stdlib logging records through mollog |
_logfire |
Optional LogfireHandler and configure_logfire() for Pydantic Logfire backends |
Install
pip install molcrafts-mollog
# with the optional logfire backend
pip install "molcrafts-mollog[logfire]"
Requires Python 3.12+. The only runtime dependency is rich.
Quick start
import mollog
mollog.configure(
level="INFO",
format="%(asctime)s %(levelname)s %(name)s %(message)s",
)
mollog.get_logger("httpx").set_level("WARNING") # silence a 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.
Documentation
The full guide: docs.molcrafts.org/mollog
(sources in docs/):
MolCrafts ecosystem
| Project | Role |
|---|---|
| molpy | Python toolkit — the shared molecular data model & workflow layer |
| molrs | Rust core — molecular data structures & compute kernels (native + WASM) |
| molpack | Packmol-grade molecular packing (Rust + Python) |
| molvis | WebGL molecular visualization & editing |
| molexp | Workflow & experiment-management platform |
| molnex | Molecular machine-learning framework |
| molq | Unified job queue — local / SLURM / PBS / LSF |
| molcfg | Layered configuration library |
| mollog | Structured logging, stdlib-compatible — this repo |
| molhub | Molecular dataset hub |
| molmcp | MCP server for the ecosystem |
| molrec | Atomistic record specification |
Contributing
See CONTRIBUTING.md.
License
BSD-3-Clause — see LICENSE.
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.3.0.tar.gz.
File metadata
- Download URL: molcrafts_mollog-1.3.0.tar.gz
- Upload date:
- Size: 48.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ce63b5089a69ddb188e842155881f0aef4728f1d2229597f9f8d5da17b23870
|
|
| MD5 |
63dd05aa511b984b4e14053aed6cdf0f
|
|
| BLAKE2b-256 |
7ad83bccffd0be892859bd74c0c29e60419455bce1440d9b8e76b9d4673f6c01
|
Provenance
The following attestation bundles were made for molcrafts_mollog-1.3.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.3.0.tar.gz -
Subject digest:
4ce63b5089a69ddb188e842155881f0aef4728f1d2229597f9f8d5da17b23870 - Sigstore transparency entry: 2407812569
- Sigstore integration time:
-
Permalink:
MolCrafts/mollog@cf460046f0adfb1047133371af318bdfdbd56d4b -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/MolCrafts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf460046f0adfb1047133371af318bdfdbd56d4b -
Trigger Event:
push
-
Statement type:
File details
Details for the file molcrafts_mollog-1.3.0-py3-none-any.whl.
File metadata
- Download URL: molcrafts_mollog-1.3.0-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c80d50b9e9f21c4ff1ea2854cbae8c6cbe702b15db8c8318b98be330c37a281e
|
|
| MD5 |
a65763ea4f76bb4ad55519861f83ddba
|
|
| BLAKE2b-256 |
d7f05adb77f4e0dd8e288f53c35d641afa8dd91290185d1b055c01ffe0bad718
|
Provenance
The following attestation bundles were made for molcrafts_mollog-1.3.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.3.0-py3-none-any.whl -
Subject digest:
c80d50b9e9f21c4ff1ea2854cbae8c6cbe702b15db8c8318b98be330c37a281e - Sigstore transparency entry: 2407812852
- Sigstore integration time:
-
Permalink:
MolCrafts/mollog@cf460046f0adfb1047133371af318bdfdbd56d4b -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/MolCrafts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf460046f0adfb1047133371af318bdfdbd56d4b -
Trigger Event:
push
-
Statement type: