Engine logger names are unpredictable

Issue #1555 resolved
Former user created an issue

An engine logger's name is based on the engine's instance ID. This makes it impossible to preconfigure certain engines in a Python log-configure file because the engine has not been created. An example would be to silence an oververbose engine while logging most engines.

If create_engine took a 'name' argument, that name could be used in the logger name, which would make it predictable. Example:

engine = create_engine("mysql://...", name="stats")

[logger_stats](logger_stats)
level = WARN
handlers =
qualname = sqlalchemy.engine.base.Engine.stats

[logger_sqlalchemy](logger_sqlalchemy)
level = INFO
handlers =
qualname = sqlalchemy.engine

Comments (8)

  1. Former user Account Deleted

    Some fixes added.

    The patch now does not break existing code (the old patch was broken, I have overridden it).

    This still needs a patch to update the documentation and a test suite. As for the test suite, unfortunately I have no idea how this feature should be tested.

  2. Former user Account Deleted

    Perhaps the ident attribute in the Engine and Pool should default to :

      hex(id(self))
    

    or, to follow current code,

      '0x...%s' % hex(id(self))[-4:](-4:)
    

    instead of None ?

    Should we use a function, instead of an attribute?

  3. Log in to comment