diff options
Diffstat (limited to 'searx/metrics')
| -rw-r--r-- | searx/metrics/error_recorder.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/searx/metrics/error_recorder.py b/searx/metrics/error_recorder.py index c5de008cc..37594e5e8 100644 --- a/searx/metrics/error_recorder.py +++ b/searx/metrics/error_recorder.py @@ -5,7 +5,8 @@ from urllib.parse import urlparse from httpx import HTTPError, HTTPStatusError from searx.exceptions import (SearxXPathSyntaxException, SearxEngineXPathException, SearxEngineAPIException, SearxEngineAccessDeniedException) -from searx import logger, searx_parent_dir +from searx import searx_parent_dir +from searx.engines import engines errors_per_engines = {} @@ -47,7 +48,7 @@ class ErrorContext: def add_error_context(engine_name: str, error_context: ErrorContext) -> None: errors_for_engine = errors_per_engines.setdefault(engine_name, {}) errors_for_engine[error_context] = errors_for_engine.get(error_context, 0) + 1 - logger.debug('%s: %s', engine_name, str(error_context)) + engines[engine_name].logger.warning('%s', str(error_context)) def get_trace(traces): @@ -73,9 +74,11 @@ def get_request_exception_messages(exc: HTTPError)\ status_code = None reason = None hostname = None - if hasattr(exc, 'request') and exc.request is not None: + if hasattr(exc, '_request') and exc._request is not None: + # exc.request is property that raise an RuntimeException + # if exc._request is not defined. url = exc.request.url - if url is None and hasattr(exc, 'response') and exc.respones is not None: + if url is None and hasattr(exc, 'response') and exc.response is not None: url = exc.response.url if url is not None: hostname = url.host |