Ok, simply and fix up this crap.
[kiosk.git] / decorators.py
index 7a088796a9cce63616412a8cbfccf16c2f8bb2fa..9995bd67ecae0479fdd3c2353eb0da05e5766b7a 100644 (file)
@@ -1,24 +1,29 @@
+#!/usr/bin/env python3
+
 from datetime import datetime
 import functools
+import logging
+
+
+logger = logging.getLogger(__file__)
 
-def invokation_logged(func):
+
+def invocation_logged(func):
     @functools.wraps(func)
     def wrapper(*args, **kwargs):
-        now = datetime.now()
-        timestamp = now.strftime("%d-%b-%Y (%H:%M:%S.%f)")
-        print("%s(%s): Entered function" % (func.__name__, timestamp))
+        logger.debug(f'Entered {func.__qualname__}')
         ret = func(*args, **kwargs)
-        now = datetime.now()
-        timestamp = now.strftime("%d-%b-%Y (%H:%M:%S.%f)")
-        print("%s(%s): Exited function" % (func.__name__, timestamp))
+        logger.debug(f'Exited {func.__qualname__}')
         return ret
+
     return wrapper
 
+
 # Test
-#@invokation_logged
-#def f(x):
+# @invocation_logged
+# def f(x):
 #    print(x * x)
 #    return x * x
 #
-#q = f(10)
-#print(q)
+# q = f(10)
+# print(q)