From: Mike Bayer Date: Wed, 22 Aug 2007 18:08:10 +0000 (+0000) Subject: - tightened down the screws on logging a little bit X-Git-Tag: rel_0_4beta4~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3917532bc9c2a37158596055028d95e710fff91;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - tightened down the screws on logging a little bit --- diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index c13c1d9468..496af751b4 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -672,7 +672,8 @@ class Connection(Connectable): def _begin_impl(self): if self.__connection.is_valid: - self.__engine.logger.info("BEGIN") + if self.__engine._should_log_info: + self.__engine.logger.info("BEGIN") try: self.__engine.dialect.do_begin(self.connection) except Exception, e: @@ -680,7 +681,8 @@ class Connection(Connectable): def _rollback_impl(self): if self.__connection.is_valid: - self.__engine.logger.info("ROLLBACK") + if self.__engine._should_log_info: + self.__engine.logger.info("ROLLBACK") try: self.__engine.dialect.do_rollback(self.connection) except Exception, e: @@ -689,7 +691,8 @@ class Connection(Connectable): def _commit_impl(self): if self.__connection.is_valid: - self.__engine.logger.info("COMMIT") + if self.__engine._should_log_info: + self.__engine.logger.info("COMMIT") try: self.__engine.dialect.do_commit(self.connection) except Exception, e: @@ -1168,11 +1171,6 @@ class Engine(Connectable): return self.pool.unique_connection() - def log(self, msg): - """Log a message using this SQLEngine's logger stream.""" - - self.logger.info(msg) - class ResultProxy(object): """Wraps a DB-API cursor object to provide easier access to row columns. diff --git a/lib/sqlalchemy/logging.py b/lib/sqlalchemy/logging.py index 2ced66109e..caaecf3027 100644 --- a/lib/sqlalchemy/logging.py +++ b/lib/sqlalchemy/logging.py @@ -66,10 +66,15 @@ def is_info_enabled(logger): return logger.isEnabledFor(logging.INFO) def instance_logger(instance, echoflag=None): - if echoflag: + if echoflag is not None: default_logging(_get_instance_name(instance)) l = logging.getLogger(_get_instance_name(instance)) - l.setLevel(echoflag == 'debug' and logging.DEBUG or logging.INFO) + if echoflag == 'debug': + l.setLevel(logging.DEBUG) + elif echoflag is True: + l.setLevel(logging.INFO) + elif echoflag is False: + l.setLevel(logging.NOTSET) else: l = logging.getLogger(_get_instance_name(instance)) instance._should_log_debug = l.isEnabledFor(logging.DEBUG) diff --git a/test/engine/parseconnect.py b/test/engine/parseconnect.py index 035a8d9cfc..157afeb2fc 100644 --- a/test/engine/parseconnect.py +++ b/test/engine/parseconnect.py @@ -57,13 +57,11 @@ class CreateEngineTest(PersistTest): config = { 'sqlalchemy.url':'postgres://scott:tiger@somehost/test?fooz=somevalue', - 'sqlalchemy.echo':'1', 'sqlalchemy.pool_recycle':50 } e = engine_from_config(config, module=dbapi) assert e.pool._recycle == 50 - assert e.echo is True assert e.url == url.make_url('postgres://scott:tiger@somehost/test?fooz=somevalue') def test_custom(self):