make error reporting for extension loading quieter

Only log the full traceback for an import error from an extension if
debug logging is enabled. This avoids spurious tracebacks in the log
when an application probes for all available extensions or when a
dependency of an extension is not installed (in that case the error
message itself should be sufficient to debug the issue).

Change-Id: I43c24f3791d575c2ecf0d08d82d9de5d74ec1150
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-07-12 08:33:18 -04:00
parent f68325fc48
commit 4ec5022e4b
1 changed files with 9 additions and 2 deletions

View File

@ -170,8 +170,15 @@ class ExtensionManager(object):
if self._on_load_failure_callback is not None:
self._on_load_failure_callback(self, ep, err)
else:
LOG.error('Could not load %r: %s', ep.name, err)
LOG.exception(err)
# Log the reason we couldn't import the module,
# usually without a traceback. The most common
# reason is an ImportError due to a missing
# dependency, and the error message should be
# enough to debug that. If debug logging is
# enabled for our logger, provide the full
# traceback.
LOG.error('Could not load %r: %s', ep.name, err,
exc_info=LOG.isEnabledFor(logging.DEBUG))
return extensions
def _load_one_plugin(self, ep, invoke_on_load, invoke_args, invoke_kwds,