Caller-aware Rich logging for Python with rate limits, file output, warning hooks, and release-aware defaults.
Project description
✨ Features
- Caller-aware helpers: Module-level helpers resolve the first visible caller so log records keep useful logger names, functions, and line numbers.
- Rich output everywhere: Console and file handlers share Rich rendering, compact columns, highlighted messages, and Rich tracebacks.
- Per-record rate limits: Add
extra={"limits": "1/minute"}orLimitOptionsto suppress noisy repeated records. - Process hooks:
init()captures warnings and installs hooks for uncaught and unraisable exceptions. - Release-aware defaults: Development and prerelease code can log more verbosely while stable installed packages stay quiet.
📦 Installation
uv add liblaf-logging
🚀 Quick Start
import liblaf.logging
liblaf.logging.init(force=True)
liblaf.logging.info("ready")
init() configures process-wide logging. When it manages handlers itself, it
creates a Rich console handler, optionally creates a Rich-formatted file handler,
and attaches LimitsFilter to those managed handlers.
Use the module-level helpers when shared helpers should log as their caller.
import liblaf.logging
def announce() -> None:
liblaf.logging.info("starting")
🚦 Rate-Limited Records
import liblaf.logging
liblaf.logging.warning(
"still waiting",
extra={"limits": "1/minute"},
)
For shared buckets or custom 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
Runtime settings are backed by liblaf-conf and the LOG_ environment prefix.
LOG_LEVEL=INFO LOG_FILE=logs/app.log python app.py
Settings control the default level, optional file path, timestamp format, relative timestamp display, hidden-frame prefixes, and release-aware traceback or warning filtering.
⌨️ 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.0.tar.gz.
File metadata
- Download URL: liblaf_logging-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
939e92a49a342cc40d5c7bf080c16c0a88722814d5db11b8a10a5f8d8d761c4f
|
|
| MD5 |
67767343d29769956131a45a07b6351d
|
|
| BLAKE2b-256 |
9eb20d06de1d1842f5a9251bfc45dbcc42da9d12f355656b93181ca353679e55
|
Provenance
The following attestation bundles were made for liblaf_logging-0.1.0.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.0.tar.gz -
Subject digest:
939e92a49a342cc40d5c7bf080c16c0a88722814d5db11b8a10a5f8d8d761c4f - Sigstore transparency entry: 1632560641
- Sigstore integration time:
-
Permalink:
liblaf/logging@ae593e5d0f85b23796e136f0572b0f60aadd2909 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/liblaf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yaml@ae593e5d0f85b23796e136f0572b0f60aadd2909 -
Trigger Event:
release
-
Statement type:
File details
Details for the file liblaf_logging-0.1.0-py3-none-any.whl.
File metadata
- Download URL: liblaf_logging-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.7 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 |
2b8ba76fa69ddd6fea68be6f80a1a178408d20dc5d8bf7975d1242520cc9f9dc
|
|
| MD5 |
30b2ab1c315501fd87b5d75bbf6401c7
|
|
| BLAKE2b-256 |
53aa389974b6438c2e4946665491ff4ce83bff6ab1a61b46a0c315da7352d7b5
|
Provenance
The following attestation bundles were made for liblaf_logging-0.1.0-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.0-py3-none-any.whl -
Subject digest:
2b8ba76fa69ddd6fea68be6f80a1a178408d20dc5d8bf7975d1242520cc9f9dc - Sigstore transparency entry: 1632560664
- Sigstore integration time:
-
Permalink:
liblaf/logging@ae593e5d0f85b23796e136f0572b0f60aadd2909 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/liblaf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yaml@ae593e5d0f85b23796e136f0572b0f60aadd2909 -
Trigger Event:
release
-
Statement type: