about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gn_libs/debug.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/gn_libs/debug.py b/gn_libs/debug.py
index 6b7173b..c1b896e 100644
--- a/gn_libs/debug.py
+++ b/gn_libs/debug.py
@@ -1,6 +1,6 @@
 """Debug utilities"""
 import logging
-from flask import current_app
+import importlib.util
 
 __this_module_name__ = __name__
 
@@ -8,10 +8,16 @@ __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)
+    flask_spec = importlib.util.find_spec("flask")
+    if bool(flask_spec):
+        current_app = importlib.import_module("flask").current_app
+        return (
+            logging.getLogger(name)
+            if not bool(current_app)
+            else current_app.logger)
+
+    return logging.getLogger(name)
+
 
 def __pk__(*args):
     """Format log entry"""