1 2 3 4 5 6 7 8 9 10 | from django.db import connection
class TerminalLogging:
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
|
More like this
- Color SQL logging middleware by moe 5 years, 3 months ago
- Output sql_queries in Firebug console when in debug mode by wojas 3 years, 2 months ago
- another request logging middleware with request time and extra info by yoav 1 year, 5 months ago
- SQL Log To Console Middleware by davepeck 3 years, 9 months ago
- Debug Page Load Time Stats Middleware by udfalkso 5 years, 9 months ago
Comments
Where the connection object on the 5th line comes from?
#
from django.db import connection
#
I guess it would be helpful to include that line
to the snippet itself :)
#