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:
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:
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:
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.
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)
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):