logging: local functions ==> loss of lineno

Peter Otten __peter__ at web.de
Sat Mar 20 09:36:22 CET 2010


Jean-Michel Pichavant wrote:

> You are still accessing the private attribute of the  module logging.

Just reading it is a significantly more conservative approach than setting 
it to an object with an unusual notion of equality ;)

> My previous remark was misleading, in fact there's nothing you can do
> about it.

How about replacing logging._srcfile with fixname(logging.__file__)?

> _srcfile is not meant to be used elsewhere than in the logging module
> itself.

> However, I don't wanna sound like I'm rejecting this solution, 1st the
> OP is satisified with it and since this solution is working, it is still
> more helpful than anyone noticing that you've accessed a private
> attribute (some will successfully argue that python allows to do so).

Yeah, I had hoped that I could get away without drawing the "consenting 
adults" wildcard...
 
> At the very begining of this thread I've provided a complete different
> approach, instead of using the builtin 'filename' and 'lineno' field of
> the logging, use custom fileds with the extra parameter.
> 
> It has also some drawbacks but could be a possible alternative.

Having two filename/lineno sets ist likely to confuse.

Peter



More information about the Python-list mailing list