I was recently trying to change the logging from the default to INFO
for sqlalchemy.engine.
This works great - so long as I do it at startup, before I make any
connections, etc, however once I've created my engine instance I don't
seem to be able to change the logging level, at least not in the
expected/obvious way.
sess = make_session()
some_obj = sess.query(....)
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
sess.refresh(some_obj)
I tracked this to the _should_log_info attribute on the engine instance itself.
Thus, I would be able to change the level to anything except INFO or
DEBUG and get the behavior I expect, but being unable to use INFO or
DEBUG (unless set initially) threw me for a bit.
I assume that the purpose of this is to save performance?
I note that the way much of the logging (esp. in pool.py) seems to be
written is like this:
somelogger.log("String ..." % (var1,var2,var3))
and of course, regardless of the loglevel specified this always
interpolates the variables - a fairly significant performance penalty
for sure.
Shouldn't the style be:
somelogger("String ...", var1,var2,var3)
which prevents interpolation unless the loglevel is actually
sufficient? Would that not obviate the need for _should_log_info (and
_should_log_debug) ??
I'm willing to supply a patch that changes the format of the calls to
the logging system if that's useful.
--
Jon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---