summaryrefslogtreecommitdiff
path: root/kvmd/logging.py
blob: 838e13d15cad25f22533a936608e0e6859cccc21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)