def test_py3_exception_no_traceback(self): """ Exceptions without tracebacks are simply returned with None for traceback. """ e = ValueError() assert (e.__class__, e, None) == _figure_out_exc_info(e)
def test_obtains_exc_info_on_True(self, true_value): """ If the passed argument evaluates to True obtain exc_info ourselves. """ try: 0 / 0 except Exception: assert sys.exc_info() == _figure_out_exc_info(true_value) else: pytest.fail("Exception not raised.")
def test_obtains_exc_info_on_True(self): """ If True is passed, obtain exc_info ourselves. """ try: 0/0 except Exception: assert sys.exc_info() == _figure_out_exc_info(True) else: pytest.fail("Exception not raised.")
def log_exception_info(logger, method_name, event_dict): """ Replace an ``exc_info`` field by a ``message`` string field: """ exc_info = event_dict.pop("exc_info", None) if exc_info: event_dict["message"] = _format_exception( _figure_out_exc_info(exc_info)) return event_dict
def test_obtains_exc_info_on_True(self): """ If True is passed, obtain exc_info ourselves. """ try: 0 / 0 except Exception: assert sys.exc_info() == _figure_out_exc_info(True) else: pytest.fail("Exception not raised.")
def format_exc_info(logger: logging.Logger, name: str, event_dict: Dict[str, Any]) -> Dict[str, Any]: """ Format exception info but also save it to another key to process in wrap_for_process_formatter """ exc_info = event_dict.pop('exc_info', None) if exc_info: event_dict['exc_info'] = _figure_out_exc_info(exc_info) event_dict['_exc_info'] = event_dict['exc_info'] return structlog.processors.format_exc_info(logger=logger, name=name, event_dict=event_dict)