Skip to main content

Payla shared utils package

Project description

===========

payla_utils python package

===========

Features

Structlog config

1) Example, structlog configuration, django

in django settings.py

from payla_utils.generic_logger.logger import GenericLogger

logger = GenericLogger(
        service_name="your_service_name",
        default_level="INFO",
).configure_structlog()

2) If you want to use structlog in django celery

in celery.py

from django.conf import settings
from payla_utils.generic_logger.logger import GenericLogger

@signals.setup_logging.connect
def receiver_setup_logging(
    loglevel, logfile, format, colorize, **kwargs
):  # pragma: no cover

    logging.config.dictConfig(settings.LOGGING)

    logger = GenericLogger(
            service_name="your_service_name",
            default_level="INFO",
    ).configure_structlog()

3) If you want to use a structlog, not Django based project

from payla_utils.generic_logger.logger import GenericLogger

logger = GenericLogger(
        service_name="your_service_name",
        default_level="INFO",
        config=your_config,
        setup_logging_dict=True
).configure_structlog()

4) How to use generic structured logger:

logger = structlog.get_logger(__name__)
logger.warning("Here is your message", key_1="value_1", key_2="value_2", key_n="value_n")

Why structured logger

  • By default, the logging frameworks outputs the traces in plain text and tools like EFK stack or Grafana Loki can’t fully process these traces.

  • Therefore, if we “structure” or send the traces in JSON format directly, all the tools can benefit of.

  • As a developer, it would be nice to be able to filter all logs by a certain customer or transaction.

  • The goal of structured logging is to solve these sorts of problems and allow additional analytics.

  • When you log something, remember that the actual consumer is the machine Grafana Loki (EFK stack), not only humans.

  • Our generic logger comes with some default context structure, but as you can see, you can introduce new keys.

  • We use structlog as wraper on standard logging library, you can check for more details structlog.

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

payla_utils-0.1.4.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

payla_utils-0.1.4-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: payla_utils-0.1.4.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.1

File hashes

Hashes for payla_utils-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a0b2056bfbed8c2459a0d38eb5492edc310e6260a63ba9f314f6bc9eba92b3b7
MD5 cf3b04108705751d5f41d40e7c2ae8ae
BLAKE2b-256 8f933667100ee19766ccfbfb2f39ff7653990b76bafa19675e1af71e9278989f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for payla_utils-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 59e8928fb8301b15358441d9c595066c52c440e40e6b7a5d34f1955d1258bfc0
MD5 267d954790157bb3e86dcdeaa144d95b
BLAKE2b-256 0a47de558bbdf2743b55800c7a95b182bf1560f0a93b34f15ec49841749f6450

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