Hello all.

I think that logging in SQLAlchemy should be a bit more straightforward.

First issue is _should_log_* properties. What for are they exist?
Standard lib's logging module allows to fine-tune levels per-logger or
per-handler. But with those strange props such simple code works not
as it should:

    engine_logger = sqlalchemy.log.instance_logger(engine)
    engine_logger.setLevel(logging.INFO)

If engine was created with echo=False there will be no logging output
(of course I haven't forgot to set up the handler). But if I call
instance_logger() again _after_ setting level to logger, output will
appear because instance_logger will set _should_log_info=True to
engine and only after that engine start to actually write INFO to log.
I can not understand the meaning of _should_log_* props.

Second question is about putting the query parameters to the log. Now
there are two log records for each query - first for the query itself
(with placeholders instead of actual data) and the second for the
query params. It makes processing log records very difficult. I think
code which logs queries should look like

        self.engine.logger.info(statement, {'parameters': parameters})

instead of

        self.engine.logger.info(statement)
        self.engine.logger.info(repr(parameters))

This will logicaly join the query text and parameters in one log
record. It is very simple to implement logging formatter which will
concatenate query text with repr(parameters) string to implement
previous behaviour. Such approach brings an ability to process queries
from log records (in custom formatter) as simple and efficient as
possible.

--
Anton Gritsay
http://angri.ru

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to