MCPcopy
hub / github.com/Delgan/loguru / InterceptHandler

Class InterceptHandler

tests/test_interception.py:9–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class InterceptHandler(logging.Handler):
10 def emit(self, record):
11 # Get corresponding Loguru level if it exists.
12 try:
13 level = logger.level(record.levelname).name
14 except ValueError:
15 level = record.levelno
16
17 # Find caller from where originated the logged message.
18 frame, depth = inspect.currentframe(), 0
19 while frame and (depth == 0 or frame.f_code.co_filename == logging.__file__):
20 frame = frame.f_back
21 depth += 1
22
23 logger.opt(depth=depth, exception=record.exc_info).log(level, record.getMessage())
24
25
26def test_formatting(writer):

Callers 12

test_formattingFunction · 0.85
test_interceptFunction · 0.85
test_remove_interceptionFunction · 0.85
test_intercept_too_lowFunction · 0.85
test_multiple_interceptFunction · 0.85
test_exceptionFunction · 0.85
test_level_is_noFunction · 0.85
test_level_exist_builtinFunction · 0.85
test_level_exists_customFunction · 0.85

Calls

no outgoing calls

Tested by 12

test_formattingFunction · 0.68
test_interceptFunction · 0.68
test_remove_interceptionFunction · 0.68
test_intercept_too_lowFunction · 0.68
test_multiple_interceptFunction · 0.68
test_exceptionFunction · 0.68
test_level_is_noFunction · 0.68
test_level_exist_builtinFunction · 0.68
test_level_exists_customFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…