only show error_summary for warning and error messages
Further reduce the clutter from error_summary by only including it when the log message will be emitted for the warning level or above. Change-Id: Ia46a7e569b875cd75fec652dfe8a4d73661dfda8 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
33d76a5d29
commit
97e9a79fe2
|
@ -98,15 +98,15 @@ def _get_error_summary(record):
|
|||
|
||||
If there is no active exception, return the default.
|
||||
|
||||
If the record is being logged at debug level, return an empty
|
||||
string.
|
||||
If the record is being logged below the warning level, return an
|
||||
empty string.
|
||||
|
||||
If there is an active exception, format it and return the
|
||||
resulting string.
|
||||
|
||||
"""
|
||||
error_summary = ''
|
||||
if record.levelno == logging.DEBUG:
|
||||
if record.levelno < logging.WARNING:
|
||||
return ''
|
||||
|
||||
if record.exc_info:
|
||||
|
|
|
@ -503,7 +503,7 @@ class JSONFormatterTestCase(LogTestBase):
|
|||
try:
|
||||
raise RuntimeError('test_exception')
|
||||
except RuntimeError:
|
||||
self.log.info('testing', context=ctxt)
|
||||
self.log.warning('testing', context=ctxt)
|
||||
data = jsonutils.loads(self.stream.getvalue())
|
||||
self.assertIn('error_summary', data)
|
||||
self.assertEqual('RuntimeError: test_exception',
|
||||
|
@ -577,7 +577,7 @@ class FluentFormatterTestCase(LogTestBase):
|
|||
try:
|
||||
raise RuntimeError('test_exception')
|
||||
except RuntimeError:
|
||||
self.log.info('testing', context=local_context)
|
||||
self.log.warning('testing', context=local_context)
|
||||
data = jsonutils.loads(self.stream.getvalue())
|
||||
self.assertIn('error_summary', data)
|
||||
self.assertEqual('RuntimeError: test_exception',
|
||||
|
@ -692,7 +692,7 @@ class ContextFormatterTestCase(LogTestBase):
|
|||
try:
|
||||
raise RuntimeError('test_exception_logging')
|
||||
except RuntimeError:
|
||||
self.log.info(message, context=ctxt)
|
||||
self.log.warning(message, context=ctxt)
|
||||
expected = 'RuntimeError: test_exception_logging\n'
|
||||
self.assertTrue(self.stream.getvalue().endswith(expected))
|
||||
|
||||
|
@ -709,7 +709,7 @@ class ContextFormatterTestCase(LogTestBase):
|
|||
try:
|
||||
raise ignore('test_exception_logging')
|
||||
except ignore as e:
|
||||
self.log.info(message, context=ctxt)
|
||||
self.log.warning(message, context=ctxt)
|
||||
expected = '{}: {}'.format(e.__class__.__name__, e)
|
||||
self.assertNotIn(expected, self.stream.getvalue())
|
||||
|
||||
|
@ -724,7 +724,7 @@ class ContextFormatterTestCase(LogTestBase):
|
|||
try:
|
||||
raise RuntimeError('test_exception_logging')
|
||||
except RuntimeError:
|
||||
self.log.info(message, context=ctxt)
|
||||
self.log.warning(message, context=ctxt)
|
||||
expected = 'A RuntimeError: test_exception_logging'
|
||||
self.assertTrue(self.stream.getvalue().startswith(expected))
|
||||
|
||||
|
|
Loading…
Reference in New Issue