Pretty Python JSON logs
Project description
pretty-json-loguru
Pretty Python JSON logs with loguru.
Basic usage
from loguru import logger
from pretty_json_loguru import setup_json_loguru
setup_json_loguru(level="DEBUG")
loguru.debug("Hello", who="Friend!")
Why JSON logs?
- Optimized for both developers and automated parsers
- Load large logs into any JSON viewer to expand and inspect every field
How it looks
Vanilla loguru
pretty-json-loguru
API
def setup_json_loguru(
level: str = "DEBUG",
traceback: Literal["attach", "extra", "drop"] = "attach",
colorize: bool = True,
remove_existing_sinks: bool = True,
keys: List[str] = ["ts", "msg", "source", "extra", "error", "traceback", "level"],
):
"""Set up pretty-json-loguru logger.
Parameters
----------
level : str
Logging level. One of `["DEBUG", "INFO", "SUCCESS", "WARNING", "ERROR", "CRITICAL"]`.
traceback : Literal["attach", "extra", "drop"]
"attach" appends the traceback to the log;
"extra" adds it to the extra field;
"drop" discards it.
colorize : bool
Adds colors to the log.
keys : List[str]
Keys to include in the log from the list `["ts", "msg", "source", "extra", "error", "traceback", "level", "module"]`.
`module` is the only key that's not included by default.
`extra` is a placeholder for extra fields.
remove_existing_sinks : bool
Removes existing sinks.
...
better_exceptions
Install better-exceptions for prettier tracebacks (used by default in loguru if installed)
License
MIT License
Author
Mark Lidenberg marklidenberg@gmail.com
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
pretty_json_loguru-0.2.3.tar.gz
(46.2 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 pretty_json_loguru-0.2.3.tar.gz.
File metadata
- Download URL: pretty_json_loguru-0.2.3.tar.gz
- Upload date:
- Size: 46.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0903a190d65e6a1846514201acad36bbbdfc33498427397f298cbd171ffc4d0d
|
|
| MD5 |
d8875d8daee2132bcae6ee053ea14064
|
|
| BLAKE2b-256 |
2764fa2675d8a304a9f7b19ca2dc47ec8ba4ff8fa1814d4159f7250605c34ad3
|
File details
Details for the file pretty_json_loguru-0.2.3-py3-none-any.whl.
File metadata
- Download URL: pretty_json_loguru-0.2.3-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b6b98ae895187b9b334ea1a6ea56b4db38f08dec7b1cdf626931a6627b174cf
|
|
| MD5 |
61965297e219e0069ebec9ad2c5f6feb
|
|
| BLAKE2b-256 |
df69e5ed9e9df36fe92375bbde70b2736840f73176c72184f92f97da82095204
|