Skip to main content

Decorator which logs the wrapped function/method.

Project description

Decorator which logs the wrapped function/method.

The following are logged:

1. name of the function called
2. arg(s) passed for the function called (if any)
3. kwarg(s) passed for the function called (if any)
4. execution time of the function called (in seconds)

* also catches and logs any **exceptions** raised *gracefully*.

**Quick Installation:**

``pip install iologger``

**Simply attach to your functions/methods:**
from iologger import iologger

def sample_function(simple_arg: str, simple_kwarg: str='yes') -> str:
return simple_arg + " " + simple_kwarg

**Just setup your logging handler and it will start working:**
>>> from sys import stdout
... from logbook import StreamHandler
... stdout_handler = StreamHandler(stdout)
... stdout_handler.push_application()
>>> sample_function("test-string", simple_kwarg="no")

[2017-01-29 18:48:50.170606] DEBUG: IOL - sample_function: Starting...
[2017-01-29 18:48:50.171035] DEBUG: IOL - sample_function: passed args/kwargs = {'args': ('test-string',), 'kwargs': {'simple_kwarg': 'no'}}
[2017-01-29 18:48:50.171197] DEBUG: IOL - sample_function: returned: 'test-string no'
[2017-01-29 18:48:50.171319] INFO: IOL - sample_function: ...Finished (3.3e-06 seconds)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for iologger, version 1.0.6
Filename, size File type Python version Upload date Hashes
Filename, size iologger-1.0.6-py2.py3-none-any.whl (8.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page