From 83f92a1bf8bf0074c48744de903cf0ba7863e2d9 Mon Sep 17 00:00:00 2001
From: pswain <peter.swain@ed.ac.uk>
Date: Fri, 26 Apr 2024 13:34:58 +0100
Subject: [PATCH] agora.logging to agora.logging_timer

---
 src/agora/logging_timer.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 src/agora/logging_timer.py

diff --git a/src/agora/logging_timer.py b/src/agora/logging_timer.py
new file mode 100644
index 0000000..6eb1bea
--- /dev/null
+++ b/src/agora/logging_timer.py
@@ -0,0 +1,16 @@
+import logging
+from time import perf_counter
+
+
+def timer(func):
+    """Log duration of a function into the aliby log file."""
+
+    def wrap_func(*args, **kwargs):
+        t1 = perf_counter()
+        result = func(*args, **kwargs)
+        logging.getLogger("aliby").debug(
+            f"{func.__qualname__} took {(perf_counter()-t1):.4f}s"
+        )
+        return result
+
+    return wrap_func
-- 
GitLab