コード例 #1
0
ファイル: test_processors.py プロジェクト: dikoufu/structlog
 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)
コード例 #2
0
 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)
コード例 #3
0
 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.")
コード例 #4
0
ファイル: test_processors.py プロジェクト: dikoufu/structlog
 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.")
コード例 #5
0
ファイル: logging.py プロジェクト: uishon/Sefaria-Project
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
コード例 #6
0
 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.")
コード例 #7
0
ファイル: test_processors.py プロジェクト: hynek/structlog
 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.")
コード例 #8
0
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)