Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging All Exceptions in a pyqt4 app

What's the best way to log all of the exceptions in a pyqt4 application using the standard python logging api?

I've tried wrapping exec_() in a try, except block, and logging the exceptions from that, but it only logs exceptions from the initialization of the app.

As a temporary solution, I wrapped the most important methods in try, except blocks, but that can't be the only way to do it.

like image 652
Brad Zeis Avatar asked Jun 18 '09 20:06

Brad Zeis


1 Answers

You need to override sys.excepthook

def my_excepthook(type, value, tback):
    # log the exception here

    # then call the default handler
    sys.__excepthook__(type, value, tback) 

sys.excepthook = my_excepthook
like image 133
dF. Avatar answered Oct 09 '22 21:10

dF.