loguru fast wrapping supports fastapi
Project description
FastLOG is a lightweight wrapper around Loguru that offers Prometheus metrics, automatic `trace_id`, colourful output, and a dead‑simple configuration API.
✨ Features
- Zero‑config out of the box –
from fastlog-io import log; log.info("hello")works instantly. - Unified interface –
configure()+get_log(name)keep formatting consistent across modules. - Automatic
trace_id– generates a 7‑char NanoID when none is bound, perfect for request tracing. - File rotation & retention – default
rotation="100 MB"; tune it viaconfigure(). - Stdlib compatibility – built‑in
reset_std_logging()redirects theloggingmodule to fastlog-io.
🚀 Installation
pip install fastlog-io
Requirements
- Python ≥ 3.12
- loguru
⚡ Quickstart
from fastlog import log, configure
# override defaults if needed
configure(level="DEBUG", log_dir="./logs")
log.info("service started")
# child logger
api_log = log.bind(name="api")
api_log.debug("new request")
Console output (colours stripped):
2025-06-21 09:57:56.510 | INFO | app | -cFZrY2V | main.<module>:7 | service started
2025-06-21 09:57:56.511 | DEBUG | api | -25bJVku | main.<module>:11 | new request
🔧 Environment variables
| Variable | Default | Description |
|---|---|---|
LOG_DIR |
(empty) | Log file directory; leave blank to log to stderr only |
LOG_LEVEL |
INFO |
Minimum log level |
LOG_ROTATION |
100 MB |
File rotation policy (Loguru syntax) |
These can also be passed directly to
configure()and override environment values.
🛠 Development & Tests (powered by uv)
# run tests in a temp venv with test extras installed
uv run --with '.[test]' pytest -q
# build wheel + sdist
uv build
# verify the built wheel in a clean env
uv run --with dist/*.whl --with pytest pytest -q
📄 License
MIT © 2025 OWQ
Project details
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 fastlog_io-0.1.7.tar.gz.
File metadata
- Download URL: fastlog_io-0.1.7.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
829eedeee3f04855a24b72c59d3c244110238d4b96eccd47fb1976d6940b3e9f
|
|
| MD5 |
97d34f054ea4cb650fb965fdb6923d9c
|
|
| BLAKE2b-256 |
999e4f905686575a8fd60bf7ef1615c4cf638b2a63e1ccf4216921174d6c3456
|
File details
Details for the file fastlog_io-0.1.7-py3-none-any.whl.
File metadata
- Download URL: fastlog_io-0.1.7-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.29
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9e229f01f04e7204a111a7431fd2fdf535cdfc1bf5fd9c15b921032adf6f957
|
|
| MD5 |
88a6916fdc12a8fad7b677d7849d97d9
|
|
| BLAKE2b-256 |
39f6a1c9f105f709ea4e419c146566653a35fba93c8d846bc156e78a1a3159af
|