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],
)
| 1942 | self.send_error(500, exc_info=sys.exc_info()) |
| 1943 | |
| 1944 | def log_exception( |
| 1945 | self, |
| 1946 | typ: "Optional[Type[BaseException]]", |
| 1947 | value: Optional[BaseException], |
| 1948 | tb: Optional[TracebackType], |
| 1949 | ) -> None: |
| 1950 | """Override to customize logging of uncaught exceptions. |
| 1951 | |
| 1952 | By default logs instances of `HTTPError` as warnings without |
| 1953 | stack traces (on the ``tornado.general`` logger), and all |
| 1954 | other exceptions as errors with stack traces (on the |
| 1955 | ``tornado.application`` logger). |
| 1956 | |
| 1957 | .. versionadded:: 3.1 |
| 1958 | """ |
| 1959 | if isinstance(value, HTTPError): |
| 1960 | log_message = value.get_message() |
| 1961 | if log_message: |
| 1962 | format = "%d %s: %s" |
| 1963 | args = [value.status_code, self._request_summary(), log_message] |
| 1964 | gen_log.warning(format, *args) |
| 1965 | else: |
| 1966 | app_log.error( |
| 1967 | "Uncaught exception %s\n%r", |
| 1968 | self._request_summary(), |
| 1969 | self.request, |
| 1970 | exc_info=(typ, value, tb), # type: ignore |
| 1971 | ) |
| 1972 | |
| 1973 | def _ui_module(self, name: str, module: Type["UIModule"]) -> Callable[..., str]: |
| 1974 | def render(*args, **kwargs) -> str: # type: ignore |
no test coverage detected