code: def log_request_fail(self, method, full_url, path, body, duration, status_code=None, response=None, exception=None):
          
          # do not log 404s on HEAD requests
          if method == 'HEAD' and status_code == 404:
              return
          logger.warning(
              '%s %s [status:%s request:%.3fs]', method, full_url,
              status_code or 'N/A', duration, exc_info=exception is not None
          )
  
          # body has already been serialized to utf-8, deserialize it for logging
          # TODO: find a better way to avoid (de)encoding the body back and forth
          if body:
              try:
                  body = body.decode('utf-8', 'ignore')
              except AttributeError:
                  pass
  
          logger.debug('> %s', body)
  
          self._log_trace(method, path, body, status_code, response, duration)
  
          if response is not None:
              logger.debug('< %s', response)
docs: Log an unsuccessful API call.