[Python-Dev] Proposed additional keyword argument in logging calls

Paul Moore p.f.moore at gmail.com
Tue Nov 22 21:10:36 CET 2005

On 11/22/05, Vinay Sajip <vinay_sajip at red-dove.com> wrote:
> makeRecord will, after doing what it does now, use the extra_info argument
> as follows:
> If type(extra_info) != types.DictType, it will be ignored.
> Otherwise, any entries in extra_info whose keys are not already in the
> LogRecord's __dict__ will be added to the LogRecord's __dict__.
> Can anyone see any problems with this approach?

I'd suggest that you raise an error if extra_info doesn't act like a
dictionary - probably, just try to add its entries and let any error
pass back to the caller. You definitely want to allow dict subclasses,
and anything that acts like a dictionary. And you want to catch errors

    log(..., extra_info = "whatever")

with a format of "... %(extra_info)s..." (ie, assuming that extra_info
is a single value - it's what I expected you to propose when I started

The rest looks good (I don't have a need for it myself, but it looks
like a nice, clean solution to the problem you describe).


More information about the Python-Dev mailing list