Fix support for request= keyword arguments for logging statements.
Review Request #8750 — Created Feb. 15, 2017 and submitted
For a long time now, Djblets has provided support for providing a Django
HTTP request to logging statements through arequest=keyword argument.
This has generally worked, but some users have encountered somewhat
sporadic problems with this. This turns out to be related to our move to
usinglogging.exception()instead oflogging.error(..., exc_info=True)
in places.
logging.exception()was missing support for keyword arguments on
Python 2.6.x, 2.7.0-2.7.5, 3.0.x, and 3.1.x. 2.7.6+ and 3.2.x+ fixed
this, but anyone running an older version would not be able to use
request=or evenextra=.Along with this, any custom loggers from
logging.getLogger('...')
would fail to supportrequest=, because we only patched up the root
logger.This change fixes these issues by patching any versions of
logging.exception()that are missing keyword argument support, and
wrappinglogging.Loggerso all loggers will benefit fromrequest=.
Unit tests passed on Python 2.6 and 2.7. Previously, these new tests
failed on 2.6.Sanity-checked that exception logs (and others) worked with
request=.
Tool: Pyflakes Processed Files: djblets/log/__init__.py Tool: PEP8 Style Checker Processed Files: djblets/log/__init__.py