Skip to main content

 mollog

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

CI PyPI Python License Ruff

Documentation  ·  Quick start  ·  Ecosystem

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.


Crafted with 💚 by MolCrafts

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

molcrafts_mollog-1.3.0.tar.gz (48.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

molcrafts_mollog-1.3.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

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

Hashes for molcrafts_mollog-1.3.0.tar.gz
Algorithm Hash digest
SHA256 4ce63b5089a69ddb188e842155881f0aef4728f1d2229597f9f8d5da17b23870
MD5 63dd05aa511b984b4e14053aed6cdf0f
BLAKE2b-256 7ad83bccffd0be892859bd74c0c29e60419455bce1440d9b8e76b9d4673f6c01

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_mollog-1.3.0.tar.gz:

Publisher: release.yml on MolCrafts/mollog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file molcrafts_mollog-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for molcrafts_mollog-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c80d50b9e9f21c4ff1ea2854cbae8c6cbe702b15db8c8318b98be330c37a281e
MD5 a65763ea4f76bb4ad55519861f83ddba
BLAKE2b-256 d7f05adb77f4e0dd8e288f53c35d641afa8dd91290185d1b055c01ffe0bad718

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_mollog-1.3.0-py3-none-any.whl:

Publisher: release.yml on MolCrafts/mollog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 files

1.2.2

2 files

1.2.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page