Fix logging with request-related info not set up in the request.

Review Request #11115 — Created Aug. 3, 2020 and submitted

chipx86
Djblets
release-1.0.x
djblets

When a project is configured to include request-related information in a
format string, and something logs a message before that information is
set on the request, an exception is raised. This has occurred in various
setups in the past. It wasn't particularly common on Django 1.6, but it
happens any time there's a HTTP 404 on newer versions.

We now capture this and return an empty string for the request
information (just like we do if there's no request), avoiding this crash
and ensuring we log something useful.

Triggered a HTTP 404 on Django 1.11 and saw the exception raised, prior
to this patch. After the patch, a suitable statement was logged.

Standard logging with valid request info still works as expected.

Summary
Fix logging with request-related info not set up in the request.
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (6fbe923)
Loading...