GithubHelp home page GithubHelp logo

mamdasn / lognostic Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 646 KB

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.

License: MIT License

Python 92.31% Dockerfile 7.69%

lognostic's Introduction

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.

lognostic's People

Contributors

mamdasn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.