Caller-aware Rich logging for Python with rate limits, file output, warning hooks, and release-aware defaults.
Project description
✨ Features
- Caller-aware helpers:
liblaf.logging.info()and friends attribute shared helper logs to the first visible caller frame. - Rich console and file output: Handlers render compact time, level, location, highlighted messages, Rich renderables, pretty objects, and tracebacks.
- Per-record rate limits: Add
extra={"limits": "1/minute"}or aLimitOptionsobject to suppress noisy repeat logs. - Process hooks:
init()captures warnings, uncaught exceptions, and unraisable exceptions through the standard logging pipeline. - Release-aware defaults: Development and prerelease distributions can get louder logger defaults while stable installed modules stay at
NOTSET.
📦 Installation
uv add liblaf-logging
🚀 Quick Start
import liblaf.logging
liblaf.logging.init(force=True)
liblaf.logging.info("ready")
init() configures the root logger at INFO by default, installs Rich output,
registers TRACE and ICECREAM level names, captures warnings, and adds
exception hooks. When it creates handlers itself, each managed handler receives
a LimitsFilter.
Use the module-level helpers when library or framework glue should log as the application code that called it.
import liblaf.logging
def announce() -> None:
liblaf.logging.info("starting")
🚦 Rate Limits
Attach a limits value to an individual record.
import liblaf.logging
liblaf.logging.warning("still waiting", extra={"limits": "1/minute"})
For shared buckets, custom identifiers, or non-default costs, pass
LimitOptions.
from liblaf.logging.filters import LimitOptions
liblaf.logging.warning(
"sync retry",
extra={
"limits": LimitOptions(
"5/minute",
namespace=("sync",),
identifiers=("account-42",),
cost=1,
)
},
)
⚙️ Configuration
Settings use the LOG_ environment prefix through
liblaf-conf. The most common options are
LOG_LEVEL, LOG_FILE, LOG_TIME_RELATIVE, LOG_HIDE_FRAME, and
LOG_HIDE_STABLE_RELEASE.
LOG_LEVEL=DEBUG LOG_FILE=logs/app.log python app.py
🧭 Release-Aware Defaults
SanitizedLogger checks module files against selected installed distributions
when a logger is created without an explicit level. .devN distributions use
the development level, prerelease distributions use the prerelease level, and
stable distributions keep the normal NOTSET logger default.
The classifier expands metadata only for those selected distributions. Exact
files are matched directly, and .pth files from selected distributions add
source-tree prefixes for editable-style layouts. Stable distribution metadata is
not expanded, and direct_url.json is not followed.
⌨️ Local Development
git clone https://github.com/liblaf/logging.git
cd logging
uv sync
uv run pytest
mise run docs:build
📝 License
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 liblaf_logging-0.1.2.tar.gz.
File metadata
- Download URL: liblaf_logging-0.1.2.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c6ec09a15be6fe4b7b3f9453cbdcc460a320b51f14a498a451af5c9313bf55d
|
|
| MD5 |
98f8ecdfbf0168711e4b450381b51a62
|
|
| BLAKE2b-256 |
0a0345fad6b08cb70e14f4f672a73740dd61442452595aac5c5d31c9c5570ef9
|
Provenance
The following attestation bundles were made for liblaf_logging-0.1.2.tar.gz:
Publisher:
python-release.yaml on liblaf/logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
liblaf_logging-0.1.2.tar.gz -
Subject digest:
7c6ec09a15be6fe4b7b3f9453cbdcc460a320b51f14a498a451af5c9313bf55d - Sigstore transparency entry: 1633409902
- Sigstore integration time:
-
Permalink:
liblaf/logging@4b9d478475c29fb9623468681b8ffd11e5a082e4 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/liblaf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yaml@4b9d478475c29fb9623468681b8ffd11e5a082e4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file liblaf_logging-0.1.2-py3-none-any.whl.
File metadata
- Download URL: liblaf_logging-0.1.2-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62886ddd85af289961c492f5b21238e34dddfc1512d5b5862acbc2a0cfd25f98
|
|
| MD5 |
2004f62dd9943c26ed96fcd35e9e52ef
|
|
| BLAKE2b-256 |
7d270a3632fd22362264a250aeaac884c501354f415743b02060802c426361e6
|
Provenance
The following attestation bundles were made for liblaf_logging-0.1.2-py3-none-any.whl:
Publisher:
python-release.yaml on liblaf/logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
liblaf_logging-0.1.2-py3-none-any.whl -
Subject digest:
62886ddd85af289961c492f5b21238e34dddfc1512d5b5862acbc2a0cfd25f98 - Sigstore transparency entry: 1633409909
- Sigstore integration time:
-
Permalink:
liblaf/logging@4b9d478475c29fb9623468681b8ffd11e5a082e4 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/liblaf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yaml@4b9d478475c29fb9623468681b8ffd11e5a082e4 -
Trigger Event:
release
-
Statement type: