Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment:

> Checking fmt to match the style in the constructor of logging.Formatter

This seems a reasonable change to want to make. You would need to parse the 
format string for fields using the appropriate style. This should probably be 
via a validate() method in each of the XXXStyle classes, which is passed the 
format string and raises an exception if invalid.

> I would like to have custom fields passed in as an additional (optional) 
> argument into the constructor for logging.Formatter

If this is just a list of custom field names, it could be inferred from the 
passed format string, which will now be being parsed for fields for the 
checking described above. So there should be no need to pass an additional 
argument.

> With this, we can remove the "extra" argument in Logger.makeRecord()

We can't do this, because of the need to maintain backwards compatibility. Note 
also that custom fields can be introduced into a LogRecord in other ways, e.g. 
using Filters.

> the "KeyError" here can be misleading and confusing

It seems reasonable to make a change to re-raise such a KeyError using a more 
informative error message, perhaps as a ValueError.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34844>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to