diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-03-29 17:35:43 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-03-29 17:35:43 +0000 |
| commit | f2e822cc312b216eeab4db5bda3a73bbf9e1710e (patch) | |
| tree | 2e1962144a990056b367d162e18d8a82271201f9 | |
| parent | f0cb9083057dcf89affc64cc0c4b6d6a7ccade41 (diff) | |
| parent | 318d82b910255751e32144604ea45c9bea9a2d26 (diff) | |
| download | nova-f2e822cc312b216eeab4db5bda3a73bbf9e1710e.tar.gz nova-f2e822cc312b216eeab4db5bda3a73bbf9e1710e.tar.xz nova-f2e822cc312b216eeab4db5bda3a73bbf9e1710e.zip | |
Merge "Support timestamps as prefixes for traceback log lines."
| -rw-r--r-- | nova/log.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/nova/log.py b/nova/log.py index 60028a685..cbc757f2b 100644 --- a/nova/log.py +++ b/nova/log.py @@ -63,7 +63,7 @@ log_opts = [ '%(pathname)s:%(lineno)d', help='data to append to log format when level is DEBUG'), cfg.StrOpt('logging_exception_prefix', - default='(%(name)s): TRACE: ', + default='%(asctime)s TRACE %(name)s %(instance)s', help='prefix each line of exception output with this format'), cfg.StrOpt('instance_format', default='[instance: %(uuid)s] ', @@ -247,11 +247,16 @@ class LegacyNovaFormatter(logging.Formatter): """Format exception output with FLAGS.logging_exception_prefix.""" if not record: return logging.Formatter.formatException(self, exc_info) + stringbuffer = cStringIO.StringIO() traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], None, stringbuffer) lines = stringbuffer.getvalue().split('\n') stringbuffer.close() + + if FLAGS.logging_exception_prefix.find('%(asctime)') != -1: + record.asctime = self.formatTime(record, self.datefmt) + formatted_lines = [] for line in lines: pl = FLAGS.logging_exception_prefix % record.__dict__ |
