• 
      

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

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

    Information

    Djblets
    release-1.0.x

    Reviewers

    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 ID
    Fix logging with request-related info not set up in the request.
    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.
    bad8717334a70c2e1d011a32953a5d3bf5748082
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-2.0.x (6fbe923)