Decorators

Decoration Utilities.

misc_utils.decorators.get_timer(logger=None) → Callable[source]

Decorate a function to log how log the function took to execute.

Parameters:logger – logger to write to, print if None.

Example

>>> from misc_utils import get_timer
>>>
>>> @get_timer(logger)
>>> def test(a, **kwargs):
>>>     for i in range(a):
>>>         time.sleep(1)
>>>
>>> test(3, b=2, c=3)
>>> # [INFO] 2020-01-01 15:30:00 Call ttt(3, b=2, c=3), time: 3s.