search: do not log as errors HTTP failures in search engines (#34314)

This commit is contained in:
Frédéric Péters 2019-06-25 16:20:41 +02:00
parent f4616afea8
commit 41d884e88f
2 changed files with 6 additions and 1 deletions

View File

@ -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 []

View File

@ -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)