summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hellmann <doug@doughellmann.com>2017-06-12 18:05:31 -0400
committerDoug Hellmann <doug@doughellmann.com>2017-06-12 18:05:31 -0400
commit527a76e4e33a980c925315dc7700afcb060c365c (patch)
treeb872054ebfc574b124cfa3e626ec7a3539ffaa9f
parent34ecde516605cc2f0dfa7051ccbd8f338de0554e (diff)
downloadoslo-log-527a76e4e33a980c925315dc7700afcb060c365c.tar.gz
do not add error_summary for debug log messages3.28.1
We catch exceptions and log debug messages a lot, which results in extra occurrences of the exception when we don't need them. Change-Id: I4dd3bf65fb456afc07a8fa7d0c9869bcc266b800 Related-Bug: #1696213 Related-Bug: #1696855 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
-rw-r--r--oslo_log/formatters.py5
-rw-r--r--oslo_log/tests/unit/test_log.py2
2 files changed, 6 insertions, 1 deletions
diff --git a/oslo_log/formatters.py b/oslo_log/formatters.py
index 2f9f979..c0da7eb 100644
--- a/oslo_log/formatters.py
+++ b/oslo_log/formatters.py
@@ -98,11 +98,16 @@ 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 there is an active exception, format it and return the
resulting string.
"""
error_summary = ''
+ if record.levelno == logging.DEBUG:
+ return ''
if record.exc_info:
# Save the exception we were given so we can include the
diff --git a/oslo_log/tests/unit/test_log.py b/oslo_log/tests/unit/test_log.py
index a946d9e..9e860ab 100644
--- a/oslo_log/tests/unit/test_log.py
+++ b/oslo_log/tests/unit/test_log.py
@@ -577,7 +577,7 @@ class FluentFormatterTestCase(LogTestBase):
try:
raise RuntimeError('test_exception')
except RuntimeError:
- self.log.debug('testing', context=local_context)
+ self.log.info('testing', context=local_context)
data = jsonutils.loads(self.stream.getvalue())
self.assertIn('error_summary', data)
self.assertEqual('RuntimeError: test_exception',