logging: local functions ==> loss of lineno

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Mar 24 11:45:32 CET 2010


On Mar 24, 9:34 am, Peter Otten <__pete... at web.de> wrote:
>
> You mean you'd have to monkey-patchlogging._findCaller() instead of
> overridinglogging.Logger.findCaller()?
>
> I don't see a big advantage in that.
>

Only that you just have to replace a function, and not have to
subclass Logger + override findCaller. And it's not especially monkey-
patching if the function is put there specifically to be replaced when
needed :-)

> Another simplification might be to have setLoggerClass() implicitly set the
> root logger and to drop the distinct RootLogger class completely.

I can't remember now why I created a separate class for the root - I
thought it might have some specialization which never happened. Of
course, I'm not sure if anyone is using it, so I can't just get rid of
it. Anyway, the root logger is in some sense special so it might be
more useful in the future.

> Note that I have no strong opinion on all this. If you leave things as is
> I'm fine with that.

Yes, it's hardly a common case that the OP is mentioning. AFAIK this
is the first time it's come up. I just thought from your and Jean-
Michel's solutions that there might be a need felt by more people to
have this functionality be more flexible.

Regards,

Vinay Sajip



More information about the Python-list mailing list