diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-09-06 19:46:08 +0200 |
|---|---|---|
| committer | Alexandre Flament <alex@al-f.net> | 2021-09-10 21:49:34 +0200 |
| commit | b513917ef94d2f18e6db3228363f8089ce1ba08a (patch) | |
| tree | 7df26e78c31a6785f972d8c68e500098176c9a8a /searx/search/processors/online.py | |
| parent | 76e0f6807ccddb12ca9efe3b2343735d6e1777d4 (diff) | |
[mod] searx.metrics & searx.search: use the engine loggers
metrics & processors use the engine logger
Diffstat (limited to 'searx/search/processors/online.py')
| -rw-r--r-- | searx/search/processors/online.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/searx/search/processors/online.py b/searx/search/processors/online.py index 48a514e8a..c4ee58e11 100644 --- a/searx/search/processors/online.py +++ b/searx/search/processors/online.py @@ -10,7 +10,6 @@ import asyncio import httpx import searx.network -from searx import logger from searx.utils import gen_useragent from searx.exceptions import ( SearxEngineAccessDeniedException, @@ -20,7 +19,6 @@ from searx.exceptions import ( from searx.metrics.error_recorder import count_error from .abstract import EngineProcessor -logger = logger.getChild('searx.search.processor.online') def default_request_params(): """Default request parameters for ``online`` engines.""" @@ -146,31 +144,37 @@ class OnlineProcessor(EngineProcessor): except (httpx.TimeoutException, asyncio.TimeoutError) as e: # requests timeout (connect or read) self.handle_exception(result_container, e, suspend=True) - logger.error("engine {0} : HTTP requests timeout" - "(search duration : {1} s, timeout: {2} s) : {3}" - .format(self.engine_name, default_timer() - start_time, - timeout_limit, - e.__class__.__name__)) + self.logger.error( + "HTTP requests timeout (search duration : {0} s, timeout: {1} s) : {2}" + .format( + default_timer() - start_time, + timeout_limit, + e.__class__.__name__ + ) + ) except (httpx.HTTPError, httpx.StreamError) as e: # other requests exception self.handle_exception(result_container, e, suspend=True) - logger.exception("engine {0} : requests exception" - "(search duration : {1} s, timeout: {2} s) : {3}" - .format(self.engine_name, default_timer() - start_time, - timeout_limit, - e)) + self.logger.exception( + "requests exception (search duration : {0} s, timeout: {1} s) : {2}" + .format( + default_timer() - start_time, + timeout_limit, + e + ) + ) except SearxEngineCaptchaException as e: self.handle_exception(result_container, e, suspend=True) - logger.exception('engine {0} : CAPTCHA'.format(self.engine_name)) + self.logger.exception('CAPTCHA') except SearxEngineTooManyRequestsException as e: self.handle_exception(result_container, e, suspend=True) - logger.exception('engine {0} : Too many requests'.format(self.engine_name)) + self.logger.exception('Too many requests') except SearxEngineAccessDeniedException as e: self.handle_exception(result_container, e, suspend=True) - logger.exception('engine {0} : Searx is blocked'.format(self.engine_name)) + self.logger.exception('Searx is blocked') except Exception as e: # pylint: disable=broad-except self.handle_exception(result_container, e) - logger.exception('engine {0} : exception : {1}'.format(self.engine_name, e)) + self.logger.exception('exception : {0}'.format(e)) def get_default_tests(self): tests = {} |