Fix up arguments to logging methods.

Review Request #12704 — Created Oct. 28, 2022 and submitted

Information

Djblets
release-4.x

Reviewers

We have a special logging formatter that is used to show info when a
django HttpRequest is part of the log record. Once upon a time, the way
of getting extra information into a log record was just to pass it as
additional kwargs to the logging methods, but the modern, documented
way of doing it is to pass a single extra dict. Some of our code uses
extra, but most of it is just passing in request= as a kwarg. I've
fixed this up, plus added the request in logging methods where we had it
available but weren't plumbing it.

In addition, there were a couple instances where we were passing
exc_info=1 instead of exc_info=True. I've fixed these up to make
type checkers happier.

Ran unit tests.

Summary ID
Fix up arguments to logging methods.
We have a special logging formatter that is used to show info when a django HttpRequest is part of the log record. Once upon a time, the way of getting extra information into a log record was just to pass it as additional `kwargs` to the logging methods, but the modern, documented way of doing it is to pass a single `extra` dict. Some of our code uses `extra`, but most of it is just passing in `request=` as a kwarg. I've fixed this up, plus added the request in logging methods where we had it available but weren't plumbing it. In addition, there were a couple instances where we were passing `exc_info=1` instead of `exc_info=True`. I've fixed these up to make type checkers happier. Testing Done: Ran unit tests.
afed7adb54a4fc231365c72880c7a0a3b8db783b
Description From Last Updated

The request= is actually a custom feature of our logging add-ons. extra= was historically the way custom data went in, …

chipx86chipx86

Given the escaping for request, we should either use double quotes for the string itself or for the code sample.

chipx86chipx86
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. The request= is actually a custom feature of our logging add-ons. extra= was historically the way custom data went in, and is what request= ultimately does. So request= is actually API provided by djblets.log.

    I still prefer request= just for the convenience of it, to be honest.

    If we're for sure going to get rid of it, we should formally deprecate it.

    1. I think I'd prefer to get rid of it. It's convenient, but type checkers and static analysis get mad, and monkey-patching standard lib stuff like this seems questionable at best.

  3. 
      
david
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. djblets/log/__init__.py (Diff revisions 1 - 2)
     
     
     
     

    Given the escaping for request, we should either use double quotes for the string itself or for the code sample.

  3. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.x (9f19dbb)
Loading...