log: embed traceback in json object

This commit is contained in:
Daniel Schadt 2016-05-25 21:57:55 +02:00
parent 96b299a1fc
commit cea32ea333
2 changed files with 7 additions and 1 deletions

View File

@ -557,4 +557,6 @@ class JSONFormatter(logging.Formatter):
'lineno', 'levelno']:
obj[field] = getattr(record, field)
obj['message'] = record.getMessage()
if record.exc_info is not None:
obj['traceback'] = super().formatException(record.exc_info)
return json.dumps(obj)

View File

@ -81,6 +81,7 @@ class LogLine(testprocess.Line):
self.module = line['module']
self.function = line['funcName']
self.line = line['lineno']
self.traceback = line.get('traceback')
self.full_message = line['message']
msg_match = re.match(r'^(\[(?P<prefix>\d+s ago)\] )?(?P<message>.*)',
@ -121,7 +122,10 @@ class LogLine(testprocess.Line):
format_dict['log_color'] = ''
format_dict['reset'] = ''
format_dict.update({color: '' for color in color_names})
return log.EXTENDED_FMT.format_map(format_dict)
result = log.EXTENDED_FMT.format_map(format_dict)
if self.traceback is not None:
result += '\n' + self.traceback
return result
class QuteProc(testprocess.Process):