Skip to main content

Decorator which logs the wrapped function/method.

Project description

============
IOLogger
============
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


@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.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

iologger-1.0.6-py2.py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 2 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