▍▞ PJ logging
Simple logging with
rich Panels and
jsonl (or plain .log) files
Basic Usage
set_logger arguments, with types and defaults:
def set_logger(
name: str | None = None,
*,
jsonl_log_file_path: pathlib.Path | str | None = None,
jsonl_log_file_size: int = 100_000,
jsonl_log_backup_count: int = 3,
rich_panel_log: bool = False,
) -> logging.Logger: ...
Example, with rich's Panels only
import pj_logging
logger = pj_logging.set_logger(rich_panel_log=True)
...
logger.info("this is an info log with a rich Panel in the terminal")
Advanced usage
The set_logger function uses the logging RotatingFileHandler
(docs) for the output file
For different needs, the JsonlFormatter can be assigned to a different handler
The PanelHandler can also be imported and added to an existing logger.
With this approach, it's possible to change values of the class' attributes before adding the handler to the logger.
class PanelHandler(logging.Handler):
colors: t.ClassVar[dict[str, str]] = {
"Debug": "blue",
"Info": "green",
"Warning": "yellow",
"Error": "red",
"Critical": "red",
}
fallback_color: str = "white"
title_align: rich.align.AlignMethod = "left"
show_error_names: bool = True
Metadata
Release files for pj-logging 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pj_logging-0.1.5.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pj_logging-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / pj_logging-0.1.5.tar.gz
| Download URL | pj_logging-0.1.5.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7cd989ba1efcb7fe7435a9d58e0cd93b0169cbce9808f83da0335cd14948751
|
|
BLAKE2b-256 checksum How to use checksums |
e1ba21f5f109736e19bc7c09f5c211e6c49bbd401adbe9eab3529df63a7fca91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 10, 2025.
Transparency logRelease files / pj_logging-0.1.5-py3-none-any.whl
| Download URL | pj_logging-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7bbfd72944d3b24e6d25ce792da69e324e287f2ee44c9db49ff1e5a2c3f198d8
|
|
BLAKE2b-256 checksum How to use checksums |
0f6b91f1fca0f8fdc68acf8a5fe4f6996889e2ecb0053f3249b9c73516f0ad82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 10, 2025.
Transparency log