Changed default handler for uncaughted exceptions. Logging with level critical instead of print to stderr

This commit is contained in:
Ilya Alekseyev
2011-01-28 20:10:03 +03:00
parent 89fd5ac096
commit 6ab7fb2e1b

View File

@@ -31,6 +31,7 @@ import cStringIO
import json
import logging
import logging.handlers
import sys
import traceback
from nova import flags
@@ -191,6 +192,10 @@ class NovaLogger(logging.Logger):
kwargs.pop('exc_info')
self.error(message, **kwargs)
def handle_exception(type, value, tb):
logging.root.critical(str(value), exc_info=(type, value, tb))
sys.excepthook = handle_exception
logging.setLoggerClass(NovaLogger)