summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-06-25 14:20:41 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-06-25 14:25:27 (GMT)
commit41d884e88fc0cb679dce117ad2ad8fd7f9bdb6d8 (patch)
tree35f1fa1b170a0a7189b6bc11acf72188b13957ee
parentf4616afea8c0e7cb6bee3cb62a033b253228e065 (diff)
downloadcombo-41d884e88fc0cb679dce117ad2ad8fd7f9bdb6d8.zip
combo-41d884e88fc0cb679dce117ad2ad8fd7f9bdb6d8.tar.gz
combo-41d884e88fc0cb679dce117ad2ad8fd7f9bdb6d8.tar.bz2
search: do not log as errors HTTP failures in search engines (#34314)
-rw-r--r--combo/apps/search/models.py2
-rw-r--r--combo/utils/requests_wrapper.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/combo/apps/search/models.py b/combo/apps/search/models.py
index e1816ae..f35e086 100644
--- a/combo/apps/search/models.py
+++ b/combo/apps/search/models.py
@@ -155,6 +155,8 @@ class SearchCell(CellBase):
# be set explicitely in the URL template in the engine definition (via
# {{user_nameid}} or {{user_email}}).
kwargs['without_user'] = True
+ # don't send error traces on HTTP errors
+ kwargs['log_errors'] = 'warn'
results = requests.get(url, **kwargs).json()
if service.get('data_key'):
results['data'] = results.get(service['data_key']) or []
diff --git a/combo/utils/requests_wrapper.py b/combo/utils/requests_wrapper.py
index 7d047f8..38827c2 100644
--- a/combo/utils/requests_wrapper.py
+++ b/combo/utils/requests_wrapper.py
@@ -127,7 +127,10 @@ class Requests(RequestsSession):
extra = {}
if django_request:
extra['request'] = django_request
- logging.error('failed to %s %s (%s)', method, url, response.status_code, extra=extra)
+ if log_errors == 'warn':
+ logging.warning('failed to %s %s (%s)', method, url, response.status_code, extra=extra)
+ else:
+ logging.error('failed to %s %s (%s)', method, url, response.status_code, extra=extra)
if method == 'GET' and cache_duration and (response.status_code // 100 == 2):
cache.set(cache_key, response.content, cache_duration)