add error_summary support for fluentd formatter
Change-Id: Ia4b570bd29783540b90dd36a5d189ee6940f8ea6 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
c06db3c1d1
commit
9ccd0dca1b
|
@ -256,7 +256,8 @@ class FluentFormatter(logging.Formatter):
|
|||
'funcname': record.funcName,
|
||||
'process_name': record.processName,
|
||||
'hostname': self.hostname,
|
||||
'traceback': None}
|
||||
'traceback': None,
|
||||
'error_summary': _get_error_summary(record)}
|
||||
|
||||
# Build the extra values that were given to us, including
|
||||
# the context.
|
||||
|
|
|
@ -571,6 +571,24 @@ class FluentFormatterTestCase(LogTestBase):
|
|||
self.assertEqual('DEBUG', data['level'])
|
||||
self.assertFalse(data['traceback'])
|
||||
|
||||
def test_exception(self):
|
||||
local_context = _fake_context()
|
||||
try:
|
||||
raise RuntimeError('test_exception')
|
||||
except RuntimeError:
|
||||
self.log.debug('testing', context=local_context)
|
||||
data = jsonutils.loads(self.stream.getvalue())
|
||||
self.assertIn('error_summary', data)
|
||||
self.assertEqual('RuntimeError: test_exception',
|
||||
data['error_summary'])
|
||||
|
||||
def test_no_exception(self):
|
||||
local_context = _fake_context()
|
||||
self.log.info('testing', context=local_context)
|
||||
data = jsonutils.loads(self.stream.getvalue())
|
||||
self.assertIn('error_summary', data)
|
||||
self.assertEqual('', data['error_summary'])
|
||||
|
||||
def test_json_exception(self):
|
||||
test_msg = 'This is %s'
|
||||
test_data = 'exceptional'
|
||||
|
|
Loading…
Reference in New Issue