warning users of problems with logging

Peter Otten __peter__ at web.de
Tue Apr 4 09:22:29 EDT 2006


Chris Curvey wrote:

> The following code exists in logging/config.py
> 
>     handlers[hand] = h
> except:     #if an error occurs when instantiating a handler, too bad
>      pass    #this could happen e.g. because of lack of privileges
> 
> The problem here is that if something did go wrong instantiating the
> handler, you have no idea what the problem was (permissions, syntax
> error, wrong parameters), and later on you get a message like:
> 
> Traceback (most recent call last):
>   File "c:\python24\lib\logging\config.py", line 151, in fileConfig
>     log.addHandler(handlers[hand])
> KeyError: 'default'
> 
> I propose that we change the code so that we have a fighting chance of
> figuring out what's going on, like this:
> 
>     handlers[hand] = h
> except Exception, e:     #if an error occurs when instantiating a
> handler, too bad
>      print e                     #this could happen e.g. because of
> lack of privileges
> 
> But I'm not sure if a "print" statement is the best way to go about it.

I think this is fixed in subversion, see
http://svn.python.org/view/python/trunk/Lib/logging/config.py?rev=42074&r1=38949&r2=42074

Peter



More information about the Python-list mailing list