diff options
author | Doug Hellmann <doug@doughellmann.com> | 2017-04-24 14:35:48 -0400 |
---|---|---|
committer | Doug Hellmann <doug@doughellmann.com> | 2017-05-15 15:41:05 -0400 |
commit | 48d284a9856dbaeb2890154bb71abc55dd0bee7a (patch) | |
tree | ec2894f9414b910f10b0c94d6c5f41c33b743649 /oslo_log/log.py | |
parent | 84341f6201fdbd2a4c6dcd16db37b52c42d94a15 (diff) | |
download | oslo-log-48d284a9856dbaeb2890154bb71abc55dd0bee7a.tar.gz |
add exception summaries to the main log line
Normally when logging while there is an active exception, the exception
is formatted as a traceback and the log message string ends up on a
separate line. This change adds the 1-line summary of the exception,
including the exception class name and the text of the exception, to the
end of the log line. The traceback is retained, so that the full details
are still logged.
Adding the exception info in the formatter means that the default
excepthook function no longer needs to do that (otherwise we end up with
duplicate information on the lines logged by the excepthook). Fix the
duplication by replacing the extra traceback formatting with a static
message that there is an unhandled error.
Depends-On: Icb2e1c6d9fe40229119467e9261055d9464d331d
Change-Id: Ib29883a1b7aa665b5d3c728dd7bd53d449987191
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Diffstat (limited to 'oslo_log/log.py')
-rw-r--r-- | oslo_log/log.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/oslo_log/log.py b/oslo_log/log.py index afb73a2..b22fa97 100644 --- a/oslo_log/log.py +++ b/oslo_log/log.py @@ -37,7 +37,6 @@ try: import syslog except ImportError: syslog = None -import traceback from oslo_config import cfg from oslo_utils import importutils @@ -191,9 +190,7 @@ class KeywordArgumentAdapter(BaseLoggerAdapter): def _create_logging_excepthook(product_name): def logging_excepthook(exc_type, value, tb): extra = {'exc_info': (exc_type, value, tb)} - getLogger(product_name).critical( - "".join(traceback.format_exception_only(exc_type, value)), - **extra) + getLogger(product_name).critical('Unhandled error', **extra) return logging_excepthook |