This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Logger methods never use kwargs
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: jb098, matrixise, vinay.sajip
Priority: normal Keywords: patch

Created on 2016-10-14 15:09 by jb098, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
loggingkwargs.patch jb098, 2016-10-14 15:09 review
Messages (4)
msg278653 - (view) Author: Jordan Brennan (jb098) * Date: 2016-10-14 15:09
The methods on the Logger class e.g. logger.debug all accept **kwargs, these are passed to the _log method but they are never used.

If _log attached them as an attribute to the LogRecord object, it would allow for creation of more powerful Filter objects to be created.

You would then be able to filter log lines based on arbitrary keyword arguments.

I've attached a patch along with tests that I think would be a sensible addition and I think that this shouldn't impact existing users of the module.
msg278658 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2016-10-14 17:20
Those signatures have **kwargs for potential extension of the logging API itself (without extending the existing argument list), not for passing arguments to filters.

You can already filter completely flexibly by passing additional values  in the "extra" parameter, which writes those to the LogRecord. This can  be inspected by filters in the same way as you propose, so there seems no reason to provide another way of doing this.

N.B. Removed larry from the nosy list, as he was apparently added by accident when the "Argument Clinic" component was selected in error.
msg278670 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-10-14 22:14
In your patch, there is an assignation to self.kwargs = kwargs  but you don't use it into your code. Maybe with inheritance ?
msg284386 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2016-12-31 11:48
I'll close this - as indicated in my comment, there's no need for this enhancement, as the already available "extra" parameter performs the same function.
History
Date User Action Args
2022-04-11 14:58:38adminsetgithub: 72629
2016-12-31 11:48:59vinay.sajipsetstatus: open -> closed
resolution: wont fix
messages: + msg284386
2016-10-14 22:14:16matrixisesetnosy: + matrixise
messages: + msg278670
2016-10-14 17:20:37vinay.sajipsetnosy: - larry
messages: + msg278658
2016-10-14 15:26:35jb098setcomponents: + Library (Lib)
2016-10-14 15:16:07jb098setcomponents: - Argument Clinic
2016-10-14 15:12:15r.david.murraysetnosy: + vinay.sajip
2016-10-14 15:09:14jb098create