mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
16 lines
377 B
Python
16 lines
377 B
Python
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)
|