Short snippet to log a function's duration and keyword arguments
import time
from helpers import log_duration # Assuming the script is located in a helpers file
@log_duration
def sleeper(duration: int):
print('Good night ๐ด')
time.sleep(duration)
print('Wake up โฐ')
return 'Done!'
print(sleeper(duration=5))
# >>>
# Good night ๐ด
# Wake up โฐ
# 5.00s for sleeper duration: 5
# Done!