I want in my TB app to log all exceptions to a log file. So, I tried to use custom sys.excepthook as usual. But every exception is still raised and nothing is logged. Here is my code:
class RootController(BaseController):
secc = SecureController()
error = ErrorController()
def __init__(self):
self.installExceptHook()
super(RootController, self).__init__()
def installExceptHook(self):
def exceptHook(type, value, tb):
logger = logging.getLogger('app')
logger.critical(''.join(traceback.format_exception(type, value, tb)))
sys.excepthook = exceptHook
When I raise ValueError in index method:
@expose('app.templates.index')
def index(self, **kwargs):
raise ValueError
return dict(page = 'index')
I still get the WebError Traceback page in my browser and nothing is logged.
Do you know what am I doing wrong? Any idea?