From 03bfc4e64a73652e9cd8fa3427a3de67fccd56cb Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Mon, 15 Jul 2013 16:14:08 -0400 Subject: [PATCH] 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 --- etc/glance-api.conf | 5 +++++ etc/glance-registry.conf | 5 +++++ glance/db/sqlalchemy/api.py | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/etc/glance-api.conf b/etc/glance-api.conf index 4de3c72d5d..1ed0aabb21 100644 --- a/etc/glance-api.conf +++ b/etc/glance-api.conf @@ -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. diff --git a/etc/glance-registry.conf b/etc/glance-registry.conf index e67f7a442e..6a2f577559 100644 --- a/etc/glance-registry.conf +++ b/etc/glance-registry.conf @@ -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 diff --git a/glance/db/sqlalchemy/api.py b/glance/db/sqlalchemy/api.py index 216b7b1664..9e04b44423 100644 --- a/glance/db/sqlalchemy/api.py +++ b/glance/db/sqlalchemy/api.py @@ -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: