MCPcopy Create free account
hub / github.com/hynek/structlog / test_captures_bound_logers

Method test_captures_bound_logers

tests/test_testing.py:94–112  ·  view source on GitHub ↗

Even logs from already bound loggers are captured and their processors restored on exit.

(self)

Source from the content-addressed store, hash-verified

92 assert orig_procs is self.get_active_procs()
93
94 def test_captures_bound_logers(self):
95 """
96 Even logs from already bound loggers are captured and their processors
97 restored on exit.
98 """
99 logger = get_logger("bound").bind(foo="bar")
100 logger.info("ensure logger is bound")
101
102 with testing.capture_logs() as logs:
103 logger.info("hello", answer=42)
104
105 assert logs == [
106 {
107 "event": "hello",
108 "answer": 42,
109 "foo": "bar",
110 "log_level": "info",
111 }
112 ]
113
114 def test_captures_log_level_mapping(self):
115 """

Callers

nothing calls this directly

Calls 3

get_loggerFunction · 0.90
bindMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected