]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- tightened down the screws on logging a little bit
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 22 Aug 2007 18:08:10 +0000 (18:08 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 22 Aug 2007 18:08:10 +0000 (18:08 +0000)
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/logging.py
test/engine/parseconnect.py

index c13c1d9468383c16407e4d3cfd17b7225a4d2660..496af751b486d41eba002eff9f4e63ce421c8b91 100644 (file)
@@ -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.
 
index 2ced66109e0f4aa4b640b497ceb01b40d7beb8d3..caaecf30270e097e5417f502041978261367d694 100644 (file)
@@ -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)
index 035a8d9cfc49cdd87d404a90de07dfdb1f31225b..157afeb2fc02f95a24092a4869dc7ff5602f3f7e 100644 (file)
@@ -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):