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 details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file logging-reporter-1.0.0.tar.gz.

File metadata

  • Download URL: logging-reporter-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for logging-reporter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ab1f4eecd8c03f538bb1a77eba15cc9605d531e33c798dc05aa37cc491ca37e6
MD5 ccfcf0151ca9c3e530969c051facc198
BLAKE2b-256 7f0ab8ca6d10ccc08cbcbf46a4c322e1b0bec6cf63c87a4d78269b699a52816d

See more details on using hashes here.

File details

Details for the file logging_reporter-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: logging_reporter-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for logging_reporter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37b8855021ba376db8635ee7bb8e55c1e7a263d9d0d77a315bdc19acd86d684f
MD5 df685b2a5fc47dd3f578bc508dfe03e8
BLAKE2b-256 c2acb05efaf7ef9722f6ed1e465d4fce5c837316696198c144e0642c6da9d319

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