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

Method test_captures_logs

tests/test_testing.py:22–37  ·  view source on GitHub ↗

Log entries are captured and retain their structure.

(self)

Source from the content-addressed store, hash-verified

20
21class TestCaptureLogs:
22 def test_captures_logs(self):
23 """
24 Log entries are captured and retain their structure.
25 """
26 with testing.capture_logs() as logs:
27 get_logger().bind(x="y").info("hello", answer=42)
28 get_logger().bind(a="b").info("goodbye", foo={"bar": "baz"})
29 assert [
30 {"event": "hello", "log_level": "info", "x": "y", "answer": 42},
31 {
32 "a": "b",
33 "event": "goodbye",
34 "log_level": "info",
35 "foo": {"bar": "baz"},
36 },
37 ] == logs
38
39 def get_active_procs(self):
40 return get_config()["processors"]

Callers

nothing calls this directly

Calls 3

get_loggerFunction · 0.90
infoMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected