From: Rob Crittenden Date: Thu, 7 May 2015 19:51:23 +0000 (-0400) Subject: Add db.conn.log option to suppress sql logs by default X-Git-Tag: v1.0.0~22 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=commitdiff_plain;h=abcefb0f2eece549371f951b58144188d2ac9307 Add db.conn.log option to suppress sql logs by default The Store logging is quite verbose with a flurry of init and destroy messages with each session. Setting db.conn.log to False (default) will suppress these. If one needs to do connection tracing it can be enabled. Signed-off-by: Rob Crittenden Reviewed-by: Simo Sorce --- diff --git a/examples/ipsilon.conf b/examples/ipsilon.conf index e89f970..bd4924b 100644 --- a/examples/ipsilon.conf +++ b/examples/ipsilon.conf @@ -2,6 +2,7 @@ debug = True tools.log_request_response.on = False template_dir = "templates" +db.conn.log = False log.screen = True base.mount = "/idp" diff --git a/ipsilon/util/data.py b/ipsilon/util/data.py index eec00b5..26fa859 100644 --- a/ipsilon/util/data.py +++ b/ipsilon/util/data.py @@ -37,11 +37,13 @@ class SqlStore(Log): @classmethod def get_connection(cls, name): if name not in cls.__instances.keys(): - logging.debug('SqlStore new: %s', name) + if cherrypy.config.get('db.conn.log', False): + logging.debug('SqlStore new: %s', name) cls.__instances[name] = SqlStore(name) return cls.__instances[name] def __init__(self, name): + self.db_conn_log = cherrypy.config.get('db.conn.log', False) self.debug('SqlStore init: %s' % name) self.name = name engine_name = name @@ -61,6 +63,10 @@ class SqlStore(Log): self._dbengine = create_engine(engine_name, **pool_args) self.is_readonly = False + def debug(self, fact): + if self.db_conn_log: + super(SqlStore, self).debug(fact) + def engine(self): return self._dbengine diff --git a/templates/install/ipsilon.conf b/templates/install/ipsilon.conf index 522cb38..b57aa55 100644 --- a/templates/install/ipsilon.conf +++ b/templates/install/ipsilon.conf @@ -2,6 +2,7 @@ debug = ${debugging} tools.log_request_response.on = False template_dir = "templates" +db.conn.log = False log.screen = ${debugging} base.mount = "/${instance}"