diff options
author | Naveed Massjouni <naveedm9@gmail.com> | 2011-06-02 17:33:40 +0000 |
---|---|---|
committer | Tarmac <> | 2011-06-02 17:33:40 +0000 |
commit | 43561799ce54515552f7d14ee7df067c136b490c (patch) | |
tree | 14957ead831d67839948d87690411efcabd98117 /nova/log.py | |
parent | 6b40a9175f55fddc1350b40b995c11cdfc4a8220 (diff) | |
parent | 9fc8e71f1b201adc0a5e49ac3a94e22bf47596fb (diff) | |
download | nova-43561799ce54515552f7d14ee7df067c136b490c.tar.gz nova-43561799ce54515552f7d14ee7df067c136b490c.tar.xz nova-43561799ce54515552f7d14ee7df067c136b490c.zip |
This adds the ability to publish nova errors to an error queue.
Diffstat (limited to 'nova/log.py')
-rw-r--r-- | nova/log.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nova/log.py b/nova/log.py index 096279f7c..6909916a1 100644 --- a/nova/log.py +++ b/nova/log.py @@ -35,6 +35,7 @@ import os import sys import traceback +import nova from nova import flags from nova import version @@ -63,6 +64,7 @@ flags.DEFINE_list('default_log_levels', 'eventlet.wsgi.server=WARN'], 'list of logger=LEVEL pairs') flags.DEFINE_bool('use_syslog', False, 'output to syslog') +flags.DEFINE_bool('publish_errors', False, 'publish error events') flags.DEFINE_string('logfile', None, 'output to named file') @@ -258,12 +260,20 @@ class NovaRootLogger(NovaLogger): else: self.removeHandler(self.filelog) self.addHandler(self.streamlog) + if FLAGS.publish_errors: + self.addHandler(PublishErrorsHandler(ERROR)) if FLAGS.verbose: self.setLevel(DEBUG) else: self.setLevel(INFO) +class PublishErrorsHandler(logging.Handler): + def emit(self, record): + nova.notifier.api.notify('nova.error.publisher', 'error_notification', + nova.notifier.api.ERROR, dict(error=record.msg)) + + def handle_exception(type, value, tb): extra = {} if FLAGS.verbose: |