]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-40756: Default second argument of LoggerAdapter.__init__ to None (GH-20362)
authorArturo Escaip <arturo.escaip@gmail.com>
Tue, 26 May 2020 14:55:21 +0000 (07:55 -0700)
committerGitHub <noreply@github.com>
Tue, 26 May 2020 14:55:21 +0000 (07:55 -0700)
commit8ad052464a4e0aef9a11663b80f187087b773592
tree3d5f7ba3ac5e54bbeda3a950999b5345ed648e21
parentdb098bc1f05bd0773943e59f83489f05f28dedf8
bpo-40756: Default second argument of LoggerAdapter.__init__ to None (GH-20362)

The 'extra' argument is not always used by custom logger adapters. For
example:

```python
class IndentAdapter(logging.LoggerAdapter):
    def process(self, msg, kwargs):
        indent = kwargs.pop(indent, 1)
        return ' ' * indent + msg, kwargs
```

It is cleaner and friendlier to default the 'extra' argument to None
instead of either forcing the subclasses of LoggerAdapter to pass a None
value directly or to override the constructor.

This change is backward compatible because existing calls to
`LoggerAdapter.__init__` are already passing a value for the second
argument.

Automerge-Triggered-By: @vsajip
Lib/logging/__init__.py
Misc/NEWS.d/next/Library/2020-05-24-11-06-37.bpo-40756.7ZH83z.rst [new file with mode: 0644]