Skip to main content

A pre-configured JSON formatter for the Casavo logging format

Project description

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

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

casavo-log-formatter-1.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

casavo_log_formatter-1.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file casavo-log-formatter-1.0.2.tar.gz.

File metadata

  • Download URL: casavo-log-formatter-1.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for casavo-log-formatter-1.0.2.tar.gz
Algorithm Hash digest
SHA256 22940f1ef1120ab2a1962fc013aa4dc37f9f5161dc5b7da0e45c7b95155eb5d8
MD5 358225c3ee1758d5c4b0e15be82f2883
BLAKE2b-256 3be1dfd6b4add749083349700ae2dc46ad8091335416942d92adf33c08121cd1

See more details on using hashes here.

File details

Details for the file casavo_log_formatter-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for casavo_log_formatter-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9f398e198bcb942355b3c266cb468bbb8d73b158c9a004f5f5a8ef2c3f2784db
MD5 a66de1151cbbb39c248d51828a5e7a5e
BLAKE2b-256 73c27785a010111b2767cd15c26a647775a71dd1836e051784a57e1efa2e6954

See more details on using hashes here.

Supported by

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