summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-05-05 16:40:22 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-05-29 14:29:33 -0700
commit47bdbf095d133a6f9a2033856767347130cba27f (patch)
tree775c7c5a1c07b65b4ed5fc636f2e744939593023
parent9e8de204e407a1493ec5147ab8f37371f127ea8d (diff)
downloadoslo-db-47bdbf095d133a6f9a2033856767347130cba27f.tar.gz
Do not always adjust sqlalchemy.engine logging
Instead of messing with another libraries logger by default only adjust the levels of that logger if the connection debug is greater than or equal to zero. This allows those who have configuration files or other ways to adjust logging to not be affected by this codes level manipulation (which is likely a side-effect users would not expect). Change-Id: I8c52f595e5077627c6999deadfd748034ab02fff
-rw-r--r--oslo/db/sqlalchemy/session.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/oslo/db/sqlalchemy/session.py b/oslo/db/sqlalchemy/session.py
index 9bf4b6d..c97f682 100644
--- a/oslo/db/sqlalchemy/session.py
+++ b/oslo/db/sqlalchemy/session.py
@@ -615,15 +615,15 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None,
'convert_unicode': True,
}
- logger = logging.getLogger('sqlalchemy.engine')
-
- # Map SQL debug level to Python log level
- if connection_debug >= 100:
- logger.setLevel(logging.DEBUG)
- elif connection_debug >= 50:
- logger.setLevel(logging.INFO)
- else:
- logger.setLevel(logging.WARNING)
+ if connection_debug >= 0:
+ # Map SQL debug level to Python log level
+ logger = logging.getLogger('sqlalchemy.engine')
+ if connection_debug >= 100:
+ logger.setLevel(logging.DEBUG)
+ elif connection_debug >= 50:
+ logger.setLevel(logging.INFO)
+ else:
+ logger.setLevel(logging.WARNING)
if "sqlite" in connection_dict.drivername:
if sqlite_fk:
@@ -811,7 +811,8 @@ class EngineFacade(object):
:keyword idle_timeout: timeout before idle sql connections are reaped
(defaults to 3600)
:keyword connection_debug: verbosity of SQL debugging information.
- 0=None, 100=Everything (defaults to 0)
+ -1=Off, 0=None, 100=Everything (defaults
+ to 0)
:keyword max_pool_size: maximum number of SQL connections to keep open
in a pool (defaults to SQLAlchemy settings)
:keyword max_overflow: if set, use this value for max_overflow with