Skip to main content

Panel rich and jsonl logging.

Project description

GitHub Release PyPI Version Python Versions License

▍▞ 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

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

pj_logging-0.1.4.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pj_logging-0.1.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pj_logging-0.1.4.tar.gz.

File metadata

  • Download URL: pj_logging-0.1.4.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pj_logging-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8ef5e09290326cbfb412b9d57142cf0b77fc32a26fc61fac8e10a78668fb1b44
MD5 7bd0012179a2cacc7fe9ac825367513c
BLAKE2b-256 c3aa39bba83f472a9a8a3fcbe565c645581b248b272f69e3d044031b9f171916

See more details on using hashes here.

Provenance

The following attestation bundles were made for pj_logging-0.1.4.tar.gz:

Publisher: publish.yml on the-citto/pj-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pj_logging-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pj_logging-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pj_logging-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9e53bd139ec22082bb9d5093c880c0db4434da6920518f5e80a1ac0b89ead114
MD5 d72ebbf70c42bdabd96795870c71191c
BLAKE2b-256 ffb395cf3072bcbc13eed1380d5919e0aa9bcf180b59667726e7d3df64d32d10

See more details on using hashes here.

Provenance

The following attestation bundles were made for pj_logging-0.1.4-py3-none-any.whl:

Publisher: publish.yml on the-citto/pj-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page