Clean, colorized structured logging for Python with JSON extra fields
Project description
TidyLog
Clean, colorized structured logging for Python with JSON extra fields.
Installation
pip install tidylog
Usage
Console Logging
from tidylog import get_logger
logger = get_logger(__name__)
logger.info("User logged in", extra={"user_id": 123, "ip": "192.168.1.1"})
Output:
2024-01-15 10:30:00 - myapp - INFO - User logged in - {"user_id": 123, "ip": "192.168.1.1"}
File Logging
from tidylog import setup_file_logging
handler = setup_file_logging(
"logs/app.log",
level="DEBUG",
logger_names=["myapp", "myapp.api"],
)
Examples
# Install in development mode
poetry install
# Run examples
poetry run python examples/console_logging.py
poetry run python examples/file_logging.py
poetry run python examples/custom_formatter.py
Build & Deploy
pip install build twine
python -m build
twine upload dist/*
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
tidylog-0.2.1.tar.gz
(7.6 kB
view details)
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 tidylog-0.2.1.tar.gz.
File metadata
- Download URL: tidylog-0.2.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f95a49c62b17cf084bcc460c5453e5f6affa8a41f1a47fd1a62acbbdf0f3e04
|
|
| MD5 |
499b646acee0c09871585e74004307fc
|
|
| BLAKE2b-256 |
130672ea8b4a6dc1466b173ebdbcd790e4f7e6954fb5b3cf23549564cc4966e4
|
File details
Details for the file tidylog-0.2.1-py3-none-any.whl.
File metadata
- Download URL: tidylog-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39e92b18358f0c117cf66740aed80504422a9326705787d7cc0658142d9ea6e5
|
|
| MD5 |
adca11bea4c46b423468eb1036b7a0a6
|
|
| BLAKE2b-256 |
54f5b87dcc045588fdb6175617685e137d187ff0686e18256afb3096e704e693
|