aboutsummaryrefslogtreecommitdiff
path: root/gn2/debug.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-11-04 16:06:50 -0600
committerFrederick Muriuki Muriithi2024-11-04 16:09:11 -0600
commitfb98c5389836c71f206c03f061b95ad0c0d1761c (patch)
tree93a0ea5cb8f572b00a6b1dce4febf54f1fdec87c /gn2/debug.py
parent82a866e263751832795ccae7c2fd42088522a29c (diff)
downloadgenenetwork2-fb98c5389836c71f206c03f061b95ad0c0d1761c.tar.gz
Add a debug-logging module.
Useful for troubleshooting issues that arise on production but do not show up in local development.
Diffstat (limited to 'gn2/debug.py')
-rw-r--r--gn2/debug.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/gn2/debug.py b/gn2/debug.py
new file mode 100644
index 00000000..6b7173b4
--- /dev/null
+++ b/gn2/debug.py
@@ -0,0 +1,22 @@
+"""Debug utilities"""
+import logging
+from flask import current_app
+
+__this_module_name__ = __name__
+
+
+# pylint: disable=invalid-name
+def getLogger(name: str):
+ """Return a logger"""
+ return (
+ logging.getLogger(name)
+ if not bool(current_app)
+ else current_app.logger)
+
+def __pk__(*args):
+ """Format log entry"""
+ value = args[-1]
+ title_vals = " => ".join(args[0:-1])
+ logger = getLogger(__this_module_name__)
+ logger.debug("%s: %s", title_vals, value)
+ return value