Skip to main content

casavo-log-formatter

An utility library that exposes a pre-configured log formatter for the Casavo JSON logging format.

Installation

pip install casavo-log-formatter, or pip install casavo-log-formatter[orjson] if you prefer using orjson as a json serializer.

Usage

Referring to https://docs.python.org/3/library/logging.config.html#logging-config-dictschema, we suggest to configure your logging dictConfig by adding those 2 keys:

formatters = {
    "simple": {
        "format": "%(levelname)s %(message)s",
        "datefmt": "%H:%M:%S",
    },
    "standard": {
        "class": "casavo_log_formatter.formatters.CasavoJsonFormatter"
    },
}
handlers = {
    "stdout": {
        "level": "DEBUG",
        "class": "logging.StreamHandler",
        "formatter": "standard"
        if settings.ENVIRONMENT in ["staging", "production"]  # or whatever you use to specify the env
        else "simple",
    },
}

This will configure a simple log format for dev and the fully featured formatter for staging + dev.

Development

  • Have a local python >=3.9
  • python -m venv .venv
  • pip install -r requirements.txt
  • pre-commit install
  • pip install -e .

Test

make test or nox to launch the test matrix against Python 3.9, 3.10, 3.11

Uploading on PyPI

  • make upload

Release files for casavo-log-formatter 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for casavo-log-formatter 1.0.3
File Size Uploaded
casavo-log-formatter-1.0.3.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for casavo-log-formatter 1.0.3
File Interpreter ABI Platform
casavo_log_formatter-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / casavo-log-formatter-1.0.3.tar.gz

Download URL casavo-log-formatter-1.0.3.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a45566eeb7f1be959bbc0f71068c969b70fbf1d2864166795a91b33fc5fe8e08
BLAKE2b-256 checksum
How to use checksums
598e3ee2aeeaf030cc1b296bc1460491a6f2507a126e0eeb9b1fcedef213f807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / casavo_log_formatter-1.0.3-py3-none-any.whl

Download URL casavo_log_formatter-1.0.3-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
957ef1da5b7a6010e23852efe3f97e06a35242717f1c434c62014dae0a7c6988
BLAKE2b-256 checksum
How to use checksums
34c2a7b8b6f2da3d45886d31f91759f351575b2961565098d26f0884c7066c4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page