Skip to main content

Inspari logging utilities

Project description

This repository provides Python logging utilities.

Configuration

The inspari.logging module provides unified interface for loading logging configuration files in app code and from gunicorn. In addition, a range of utilities (service name prefixing, command line colors etc.) are provided.

An example logging configuration file is bundled (example_logging_config.json), along with an example of the usage in an application context (example_usage.py).

Stream logs

The streamlogs command line utility provides a simple way to stream logs in realtime. To enable log collection, add a handler as part of your logging configuration,

    "handlers": {
        "web": {
            "class": "inspari.logging.AzureBlobStorageHandler",
            "formatter": "simple",
            "load_dot_env": "true",
            "env_key": "ABS_CONNECTION_STRING",
            "log_local": "true"
        },
        ...
    },
    ...
    "root": {
        "level": "INFO",
        "handlers": [
            "web",
            ...
        ]
    },

and configure the logs as demonstrated in example_usage.py. The storage account to use for streaming must be specified via environment variables. In the example case, a connection string is used. Hence, for local development purposes, it is recommended to create a .env file with the content like,

ABS_CONNECTION_STRING=REDACTED

Note that by default, logs are written to container called logs, so you must create a container with this name, if it doesn't already exist. If you now run,

poetry run steamlogs

you should be getting logs in (near) realtime from all services connected to the account.

Development

Create a new Python environment with all dependencies installed,

poetry install

That's it! You can validate that the environment is setup correctly by running the tests,

poetry run coverage run -m pytest

Deployment

Update the version in pyproject.toml, and add a new entry in CHANGELOG.md. Build the project via Poetry,

poetry build

and push it to pypi,

poetry publish -u __token__ -p $INSPARI_PYPI_TOKEN

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

inspari_logging-0.1.2rc1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

inspari_logging-0.1.2rc1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file inspari_logging-0.1.2rc1.tar.gz.

File metadata

  • Download URL: inspari_logging-0.1.2rc1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.3 Linux/6.8.0-1017-azure

File hashes

Hashes for inspari_logging-0.1.2rc1.tar.gz
Algorithm Hash digest
SHA256 b6a5f476a53580539c3e55ca8eee4afe3b2b1b9c0a394165a36ec34b1bc6a7de
MD5 0c4eaaeb12e9b876564c4f0f347935ce
BLAKE2b-256 6b80e10b67424dc8f85a3250121b3ca9829308e2e4f75859aafecb127aead02e

See more details on using hashes here.

File details

Details for the file inspari_logging-0.1.2rc1-py3-none-any.whl.

File metadata

  • Download URL: inspari_logging-0.1.2rc1-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.3 Linux/6.8.0-1017-azure

File hashes

Hashes for inspari_logging-0.1.2rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 dca80b85fa7c091a8758de3ad90fc3bb39c10d63eee68463a98d707864042c95
MD5 f91b327e25c6bf43d29f7e517ede9afb
BLAKE2b-256 b220aef349c1f3525c39e4ba140f27c7a65ce0e8dab64378266a2f3c32fc3d02

See more details on using hashes here.

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