diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-13 13:53:31 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-13 13:53:31 -0500 |
| commit | 5f1fbf575915470391c5a816d99a742e64b6be25 (patch) | |
| tree | e47cc04988a835ef03f1b3bb02e5a5c4d0495e24 /lib/sqlalchemy/engine | |
| parent | 3290ac23df9eed8a61324eb68f062a7de29e549d (diff) | |
| download | sqlalchemy-5f1fbf575915470391c5a816d99a742e64b6be25.tar.gz | |
- Added "logging_name" argument to create_engine(), Pool() constructor
as well as "pool_logging_name" argument to create_engine() which
filters down to that of Pool. Issues the given string name
within the "name" field of logging messages instead of the default
hex identifier string. [ticket:1555]
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/__init__.py | 12 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/strategies.py | 3 |
3 files changed, 17 insertions, 4 deletions
diff --git a/lib/sqlalchemy/engine/__init__.py b/lib/sqlalchemy/engine/__init__.py index 8911485cb..9a53545df 100644 --- a/lib/sqlalchemy/engine/__init__.py +++ b/lib/sqlalchemy/engine/__init__.py @@ -118,7 +118,7 @@ def create_engine(*args, **kwargs): Pool. Specific dialects also accept keyword arguments that are unique to that dialect. Here, we describe the parameters that are common to most ``create_engine()`` usage. - + :param assert_unicode: Deprecated. A warning is raised in all cases when a non-Unicode object is passed when SQLAlchemy would coerce into an encoding (note: but **not** when the DBAPI handles unicode objects natively). @@ -144,6 +144,11 @@ def create_engine(*args, **kwargs): connections. Usage of this function causes connection parameters specified in the URL argument to be bypassed. + :param logging_name: String identifier which will be used within + the "name" field of logging records generated within the + "sqlalchemy.engine" logger. Defaults to a hexstring of the + object's id. + :param echo=False: if True, the Engine will log all statements as well as a repr() of their parameter lists to the engines logger, which defaults to sys.stdout. The ``echo`` attribute of @@ -153,6 +158,11 @@ def create_engine(*args, **kwargs): controls a Python logger; see :ref:`dbengine_logging` for information on how to configure logging directly. + :param pool_logging_name: String identifier which will be used within + the "name" field of logging records generated within the + "sqlalchemy.pool" logger. Defaults to a hexstring of the object's + id. + :param echo_pool=False: if True, the connection pool will log all checkouts/checkins to the logging stream, which defaults to sys.stdout. This flag ultimately controls a Python logger; see diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index ea6282954..fa0059130 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1387,17 +1387,19 @@ class TwoPhaseTransaction(Transaction): self.connection._commit_twophase_impl(self.xid, self._is_prepared) -class Engine(Connectable): +class Engine(Connectable, log.Identified): """ Connects a :class:`~sqlalchemy.pool.Pool` and :class:`~sqlalchemy.engine.base.Dialect` together to provide a source of database connectivity and behavior. """ - def __init__(self, pool, dialect, url, echo=None, proxy=None): + def __init__(self, pool, dialect, url, logging_name=None, echo=None, proxy=None): self.pool = pool self.url = url self.dialect = dialect + if logging_name: + self.logging_name = logging_name self.echo = echo self.engine = self self.logger = log.instance_logger(self, echoflag=echo) diff --git a/lib/sqlalchemy/engine/strategies.py b/lib/sqlalchemy/engine/strategies.py index 7a8856ba8..7c434105c 100644 --- a/lib/sqlalchemy/engine/strategies.py +++ b/lib/sqlalchemy/engine/strategies.py @@ -90,7 +90,8 @@ class DefaultEngineStrategy(EngineStrategy): # consume pool arguments from kwargs, translating a few of # the arguments - translate = {'echo': 'echo_pool', + translate = {'logging_name': 'pool_logging_name', + 'echo': 'echo_pool', 'timeout': 'pool_timeout', 'recycle': 'pool_recycle', 'use_threadlocal':'pool_threadlocal'} |
