コード例 #1
0
 def test_captures_logs(self):
     with testing.capture_logs() as logs:
         _config.get_logger().bind(x="y").info("hello")
         _config.get_logger().bind(a="b").info("goodbye")
     assert [
         {"event": "hello", "log_level": "info", "x": "y"},
         {"a": "b", "event": "goodbye", "log_level": "info"},
     ] == logs
コード例 #2
0
 def test_get_logger_passes_positional_arguments_to_logger_factory(self):
     """
     Ensure `get_logger` passes optional positional arguments through to
     the logger factory.
     """
     factory = call_recorder(lambda *args: object())
     configure(logger_factory=factory)
     get_logger("test").bind(x=42)
     assert [call("test")] == factory.calls
コード例 #3
0
 def test_get_logger_configures_according_to_config(self):
     b = get_logger().bind()
     assert isinstance(b._logger,
                       _BUILTIN_DEFAULT_LOGGER_FACTORY().__class__)
     assert _BUILTIN_DEFAULT_PROCESSORS == b._processors
     assert isinstance(b, _BUILTIN_DEFAULT_WRAPPER_CLASS)
     assert _BUILTIN_DEFAULT_CONTEXT_CLASS == b._context.__class__