FAQ
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?

Search Discussions

  • Peter Otten at Apr 4, 2006 at 1:22 pm

    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?revB074&r18949&r2B074

    Peter
  • Chris Curvey at Apr 4, 2006 at 2:28 pm
    So it is. Great!

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 4, '06 at 12:51p
activeApr 4, '06 at 2:28p
posts3
users2
websitepython.org

2 users in discussion

Chris Curvey: 2 posts Peter Otten: 1 post

People

Translate

site design / logo © 2018 Grokbase