Skip to main content

lognostic is a lightweight, efficient Python package designed to seamlessly integrate into existing Python applications to provide comprehensive logging statistics. ThiThis package caters to development teams seeking to optimize logging performance, diagnose issues, and understand logging loads without introducing significant overhead or complexity into their applications.

Project description

lognostic

PyPI PyPI - Python Version PyPI - License


Documentation: https://Mamdasn.github.io/lognostic

Source Code: https://github.com/Mamdasn/lognostic

PyPI: https://pypi.org/project/lognostic/


lognostic is a lightweight, efficient Python package designed to seamlessly integrate into existing Python applications to provide logging statistics. This package caters to development teams seeking to optimize logging performance, diagnose issues, and understand logging loads without introducing significant overhead or complexity into their applications.

Installation

pip install lognostic

Development

  • Clone this repository
  • Requirements:
  • Create a virtual environment and install the dependencies
poetry install
  • Activate the virtual environment
poetry shell

Custom logging Handler

The lognostic module can be integrated into logging subsystems by employing a custom logging handler:

class LogHandler(logging.Handler):
    def __init__(self, lognostic: Lognostic):
        super().__init__()
        self._lognostic = lognostic

    def emit(self, log_record: logging.LogRecord):
        self._lognostic.record(log_record)

A Lognostic instance should be given to the custom logging handler, so later logging statistics can be obtained:

lognostic = Lognostic()
loghandler = LogHandler(lognostic)
logger.addHandler(loghandler)

logger.info('This is a test log message')

lognostic.total_size() # -> returns 26

Documentation

The documentation is automatically generated from the content of the docs directory and from the docstrings found in the source code.

Testing

Run unit tests using

pytest tests

Automated test runs: The lognostic package is automatically tested through python versions 3.9 to 3.12 using GitHub's CI/CD pipeline.

Docker Usage

Build the image of the Dockerfile using

docker build -t lognostic .

Run the image with

docker run --name lognostic_instance lognostic

The docker builds the envioronment followed by running the pre-commits and unit tests.

Pre-commit

Pre-commit hooks run all the auto-formatters (e.g. black, isort), linters (e.g. mypy, flake8), and other quality checks to make sure the changeset is in good shape before a commit/push happens.

You can install the hooks with (runs for each commit):

pre-commit install

Or if you want them to run only for each push:

pre-commit install -t pre-push

Or if you want e.g. want to run all checks manually for all files:

pre-commit run --all-files

Future features and improvements

  • Data persistency: Store statistics on the disk persistency for future historical logging analysis.
  • Logging Dashboard: A web dashboard to visualize logging statistics in real-time, allowing teams to monitor logging load dynamically.
  • Throw warning/error messages if certain logging thresholds are met, such as an unusually high logging rate, to quickly identify potential issues.

This project was generated using the python-package-cookiecutter template.

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

lognostic-0.0.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

lognostic-0.0.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file lognostic-0.0.4.tar.gz.

File metadata

  • Download URL: lognostic-0.0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.5.0-1015-azure

File hashes

Hashes for lognostic-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e1c6767def343d3f26726d6de7e15940316002c4c62ace640947e25c2a12d5b8
MD5 467c2e7a03f18b4d4afecb73c01fb5fe
BLAKE2b-256 dacfadb03f63113337684f70fc1d1300ec47d32cfe42c3b80eae330a7dc70859

See more details on using hashes here.

File details

Details for the file lognostic-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: lognostic-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.5.0-1015-azure

File hashes

Hashes for lognostic-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6a43dcbb79099cb8b31663dba7e94fc394eb77f9c9726eefaacaa69973487da0
MD5 55ae9bb2bd2b5ffb264d6be2ebf10650
BLAKE2b-256 6c18125292c01f1d05288f929c83203d086ab359f0f6e54ddf994f0d760cf598

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