Eric Floehr schrieb:

> from django.db import connection
> class Logging:
>     def process_response(self, request, response):
>         for query in connection.queries:
>             print "[%s] %s" % (query['time'], "
> ".join(query['sql'].split()))
>         return response
>
> Which results in all the queries being output to standard output.  Of
> course this could be improved on, but is a base.
>

A small improvement with uses coloring (a la ruby on rails):

from django.db import connection

class Logging:
    def process_response(self, request, response):
        from sys import stdout
        if stdout.isatty():
            for query in connection.queries:
                print "\033[1;31m[%s]\033[0m \033[1m%s\033[0m" %
(query['time'], " ".join(query['sql'].split()))
        return response

Best Regards
JP


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

Reply via email to