diff --git a/awx/conf/settings.py b/awx/conf/settings.py index 5770f9052d..2f7970ec2b 100644 --- a/awx/conf/settings.py +++ b/awx/conf/settings.py @@ -5,6 +5,8 @@ import logging import sys import threading import time +import StringIO +import traceback import six @@ -62,11 +64,19 @@ __all__ = ['SettingsWrapper', 'get_settings_to_cache', 'SETTING_CACHE_NOTSET'] def _log_database_error(): try: yield - except (ProgrammingError, OperationalError) as e: + except (ProgrammingError, OperationalError): if 'migrate' in sys.argv and get_tower_migration_version() < '310': logger.info('Using default settings until version 3.1 migration.') else: - logger.warning('Database settings are not available, using defaults (%s)', e, exc_info=True) + # Somewhat ugly - craming the full stack trace into the log message + # the available exc_info does not give information about the real caller + # TODO: replace in favor of stack_info kwarg in python 3 + sio = StringIO.StringIO() + traceback.print_stack(file=sio) + sinfo = sio.getvalue() + sio.close() + sinfo = sinfo.strip('\n') + logger.warning('Database settings are not available, using defaults, logged from:\n{}'.format(sinfo)) finally: pass