Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger).
(
self,
typ: "Optional[Type[BaseException]]",
value: Optional[BaseException],
tb: Optional[TracebackType],
)
| 1775 | self.send_error(500, exc_info=sys.exc_info()) |
| 1776 | |
| 1777 | def log_exception( |
| 1778 | self, |
| 1779 | typ: "Optional[Type[BaseException]]", |
| 1780 | value: Optional[BaseException], |
| 1781 | tb: Optional[TracebackType], |
| 1782 | ) -> None: |
| 1783 | """Override to customize logging of uncaught exceptions. |
| 1784 | |
| 1785 | By default logs instances of `HTTPError` as warnings without |
| 1786 | stack traces (on the ``tornado.general`` logger), and all |
| 1787 | other exceptions as errors with stack traces (on the |
| 1788 | ``tornado.application`` logger). |
| 1789 | |
| 1790 | .. versionadded:: 3.1 |
| 1791 | """ |
| 1792 | if isinstance(value, HTTPError): |
| 1793 | if value.log_message: |
| 1794 | format = "%d %s: " + value.log_message |
| 1795 | args = [value.status_code, self._request_summary()] + list(value.args) |
| 1796 | gen_log.warning(format, *args) |
| 1797 | else: |
| 1798 | app_log.error( |
| 1799 | "Uncaught exception %s\n%r", |
| 1800 | self._request_summary(), |
| 1801 | self.request, |
| 1802 | exc_info=(typ, value, tb), # type: ignore |
| 1803 | ) |
| 1804 | |
| 1805 | def _ui_module(self, name: str, module: Type["UIModule"]) -> Callable[..., str]: |
| 1806 | def render(*args, **kwargs) -> str: # type: ignore |
no test coverage detected