Skip to main content

Lightweight logger decorators for python

Project description

Lightweight logger decorators for python

Black code style Tests
License:

MIT

What is this repository?

Extends default python logging module to make it easier to log actions before and after running functions and methods. Usefull when debugging an application and you want to see the time a function takes or when the function was called.

Features

  • Display when a function was executed

  • Display the result of a function

  • Display a value before and after a fucntion was executed

  • Display the execution time

  • Display the str and repr method of an object before and after

How do I get set up?

Use pip install git+ssh://git@github.com/2019342a/reporter to install the library. Then you are good to go!

Dependencies

logging-reporter requires colorlog to add colour to the reporter logs.

Example

from reporter.utils import create_reporter
from reporter.decorators import report_execution

# Initialise the logger
create_reporter()

@report_execution
def add(a: int, b: int) -> int:
   return a + b


add(1, 2)

You should then see in your terminal something like:

2021-05-15 11:05:53,114 - reporter - DEBUG - add was executed with args 1 2

Contact

If you have any questions, bugs or features please open a github issue.

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

logging-reporter-1.0.0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

logging_reporter-1.0.0-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

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