Projet

Général

Profil

0001-search-do-not-log-as-errors-HTTP-failures-in-search-.patch

Frédéric Péters, 25 juin 2019 16:21

Télécharger (1,88 ko)

Voir les différences:

Subject: [PATCH] search: do not log as errors HTTP failures in search engines
 (#34314)

 combo/apps/search/models.py     | 2 ++
 combo/utils/requests_wrapper.py | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
combo/apps/search/models.py
155 155
        # be set explicitely in the URL template in the engine definition (via
156 156
        # {{user_nameid}} or {{user_email}}).
157 157
        kwargs['without_user'] = True
158
        # don't send error traces on HTTP errors
159
        kwargs['log_errors'] = 'warn'
158 160
        results = requests.get(url, **kwargs).json()
159 161
        if service.get('data_key'):
160 162
            results['data'] = results.get(service['data_key']) or []
combo/utils/requests_wrapper.py
127 127
            extra = {}
128 128
            if django_request:
129 129
                extra['request'] = django_request
130
            logging.error('failed to %s %s (%s)', method, url, response.status_code, extra=extra)
130
            if log_errors == 'warn':
131
                logging.warning('failed to %s %s (%s)', method, url, response.status_code, extra=extra)
132
            else:
133
                logging.error('failed to %s %s (%s)', method, url, response.status_code, extra=extra)
131 134
        if method == 'GET' and cache_duration and (response.status_code // 100 == 2):
132 135
            cache.set(cache_key, response.content, cache_duration)
133 136

  
134
-