warning users of problems with logging

C

Chris Curvey

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.
Any thoughts?
 
P

Peter Otten

Chris said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top