warning users of problems with logging

Discussion in 'Python' started by Chris Curvey, Apr 4, 2006.

  1. Chris Curvey

    Chris Curvey Guest

    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?
     
    Chris Curvey, Apr 4, 2006
    #1
    1. Advertising

  2. Chris Curvey

    Peter Otten Guest

    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
     
    Peter Otten, Apr 4, 2006
    #2
    1. Advertising

  3. Chris Curvey

    Chris Curvey Guest

    So it is. Great!
     
    Chris Curvey, Apr 4, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Siegl
    Replies:
    0
    Views:
    969
    Stefan Siegl
    Aug 27, 2003
  2. janne
    Replies:
    0
    Views:
    9,541
    janne
    Sep 10, 2004
  3. Christoph Haas
    Replies:
    0
    Views:
    468
    Christoph Haas
    Jun 12, 2006
  4. Christoph Haas
    Replies:
    1
    Views:
    469
    Vinay Sajip
    Jun 14, 2006
  5. johnny
    Replies:
    1
    Views:
    657
    Dennis Lee Bieber
    Dec 12, 2006
Loading...

Share This Page