summaryrefslogtreecommitdiff
path: root/kvmd/logging.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/logging.py')
-rw-r--r--kvmd/logging.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/kvmd/logging.py b/kvmd/logging.py
new file mode 100644
index 00000000..838e13d1
--- /dev/null
+++ b/kvmd/logging.py
@@ -0,0 +1,15 @@
+import sys
+import logging
+
+
+# =====
+def get_logger(depth: int=1) -> logging.Logger:
+ frame = sys._getframe(1) # pylint: disable=protected-access
+ frames = []
+ while frame:
+ frames.append(frame)
+ frame = frame.f_back
+ if len(frames) - 1 >= depth:
+ break
+ name = frames[depth].f_globals["__name__"]
+ return logging.getLogger(name)