Pretty json logs in loguru
Project description
pretty-json-loguru
Pretty json loguru logs.
Basic usage
from pretty_json_loguru import setup_json_loguru
setup_json_loguru(level="DEBUG")
How it looks
loguru
pretty-json-loguru
Why JSON logs?
- Clear for developers and parsers alike.
- Paste into any JSON viewer to expand and explore fields.
API
from typing import Literal, List
def setup_json_loguru(
level: str = "DEBUG",
traceback: Literal["attach", "extra", "drop"] = "attach",
colorize: bool = True,
remove_existing_sinks: bool = True,
keys: List[Literal["ts", "module", "msg", "source", "extra", "error", "traceback", "level"]] = [
"ts",
# "module", # module is skipped by default for brevity
"msg",
"source",
"extra",
"error",
"traceback",
"level",
],
):
"""Set up loguru logger with JSON format (colored).
Parameters
----------
level : str
Logging level
traceback : Literal["attach", "extra", "drop"]
If "attach", traceback will be appended to the log, as if we use the vanilla formatter.
if "extra", traceback will be added to the extra field
if "drop", traceback will be dropped
colorize : bool
If True, colors will be added to the log. If colorize=False, vanilla traceback will be used (`traceback.format_exc()`)
keys : List[Literal["ts", "module", "msg", "source", "extra", "error", "traceback", "level"]]
List and order of keys to include in the log. `extra` is a placeholder for extra fields
remove_existing_sinks : bool
Whether to remove existing sinks
"""
...
better_exceptions
Install better_exceptions for prettier tracebacks, used by default by loguru.
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.0.tar.gz
(488.9 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.0.tar.gz.
File metadata
- Download URL: pretty_json_loguru-0.2.0.tar.gz
- Upload date:
- Size: 488.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c598146301c9d0e1b6ddac50c995b6165950a9bdb9ca046da7e536cb6ef903e
|
|
| MD5 |
366ea5bef83169c3dbb5b495287a98d3
|
|
| BLAKE2b-256 |
cb254ab9deb8d2875eca8b040b7fb4a836feedc57d2b547987d8ca1254cf7680
|
File details
Details for the file pretty_json_loguru-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pretty_json_loguru-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e850ece031abc5589f9ee0c6476cee2edff618ea1de102c4a0cc1ec081e09614
|
|
| MD5 |
413299c7021dc6600d6e9c5f6e2194c6
|
|
| BLAKE2b-256 |
7ec4ee2ee874536356ce27d2b9ce44944c9c4155335e2bb4aede4cb026961870
|