Turn off debug logging in sqlalchemy by default

This commit adds a new config option sqlalchemy_debug which is used
for enabling debug messages from sqlalchemy. Previously, this logging
was enabled whenever debug was enabled. The debug log level for
sqlalchemy prints out all SQL queries and results which is way too
verbose for most cases where just debug logging is useful. This
change disables this previous behavior by defaulting the new option
to false and decoupling it from the debug config option.

DocImpact

Change-Id: I298c40b71ed0b8772ff956f61f8d94217bce0e11
This commit is contained in:
Matthew Treinish 2013-07-15 16:14:08 -04:00
parent 093d442681
commit 03bfc4e64a
3 changed files with 15 additions and 2 deletions

View File

@ -159,6 +159,11 @@ registry_client_protocol = http
# Default: False
#db_auto_create = False
# Enable DEBUG log messages from sqlalchemy which prints every database
# query and response.
# Default: False
#sqlalchemy_debug = True
# ============ Notification System Options =====================
# Notifications can be sent when images are create, updated or deleted.

View File

@ -55,6 +55,11 @@ limit_param_default = 25
# Default: False
#db_auto_create = False
# Enable DEBUG log messages from sqlalchemy which prints every database
# query and response.
# Default: False
#sqlalchemy_debug = True
# ================= Syslog Options ============================
# Send logs to syslog (/dev/log) instead of to file specified

View File

@ -70,6 +70,9 @@ db_opts = [
cfg.BoolOpt('db_auto_create', default=False,
help=_('A boolean that determines if the database will be '
'automatically created.')),
cfg.BoolOpt('sqlalchemy_debug', default=False,
help=_('Enable debug logging in sqlalchemy which prints '
'every query and result'))
]
CONF = cfg.CONF
@ -118,7 +121,7 @@ def setup_db_env():
_RETRY_INTERVAL = CONF.sql_retry_interval
_CONNECTION = CONF.sql_connection
sa_logger = logging.getLogger('sqlalchemy.engine')
if CONF.debug:
if CONF.sqlalchemy_debug:
sa_logger.setLevel(logging.DEBUG)
@ -188,7 +191,7 @@ def get_engine():
raise
sa_logger = logging.getLogger('sqlalchemy.engine')
if CONF.debug:
if CONF.sqlalchemy_debug:
sa_logger.setLevel(logging.DEBUG)
if CONF.db_auto_create: