The SQLAlchemy default logging seems to use StreamHandler to write to
sys.stdout.
This cause a problem when writing Python CGI scripts I (unfortunately)
have to.

The problem is that the SA logger writes to sys.stdout before HTTP
headers get writen by my homegrown web cgi framework.

See snippet from SA log.py below:

[[

default_enabled = False
def default_logging(name):
   global default_enabled
   if logging.getLogger(name).getEffectiveLevel() < logging.WARN:
       default_enabled = True
   if not default_enabled:
       default_enabled = True
       handler = logging.StreamHandler(sys.stdout)
       handler.setFormatter(logging.Formatter(
           '%(asctime)s %(levelname)s %(name)s %(message)s'))
       rootlogger.addHandler(handler)

]]

To get my cgi app to work, I can either:
1.) set Echo = False or
2.) I comment out the "handler" lines in log.py above and from there
my own logger directs the SA log to my app's log file.

Both of the above ways do the trick.

Anyone with any idea how to do this in a more cleaner way?
If not, should this perhaps be suggested as change to current SA
source?

Kind regards,
-Alen Ribic

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to