Mercurial > kallithea
comparison pylons_app/lib/timerproxy.py @ 90:0c22a870bb79
logging proxy update
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 19 Apr 2010 23:03:01 +0200 |
parents | 3ada2f409c1c |
children | a5a3bcc5ee89 |
comparison
equal
deleted
inserted
replaced
89:b2c38dee135a | 90:0c22a870bb79 |
---|---|
1 from sqlalchemy.interfaces import ConnectionProxy | 1 from sqlalchemy.interfaces import ConnectionProxy |
2 import time | 2 import time |
3 import logging | 3 import logging |
4 log = logging.getLogger(__name__) | 4 log = logging.getLogger('timerproxy') |
5 | 5 |
6 class TimerProxy(ConnectionProxy): | 6 class TimerProxy(ConnectionProxy): |
7 def cursor_execute(self, execute, cursor, statement, parameters, context, executemany): | 7 def cursor_execute(self, execute, cursor, statement, parameters, context, executemany): |
8 now = time.time() | 8 now = time.time() |
9 try: | 9 try: |
10 log.info(">>>>> STARTING QUERY >>>>>") | 10 log.info(">>>>> STARTING QUERY >>>>>") |
11 return execute(cursor, statement, parameters, context) | 11 return execute(cursor, statement, parameters, context) |
12 finally: | 12 finally: |
13 total = time.time() - now | 13 total = time.time() - now |
14 log.info("Query: %s" % statement % parameters) | 14 try: |
15 log.info("Query: %s" % statement % parameters) | |
16 except TypeError: | |
17 log.info("Query: %s %s" % (statement, parameters)) | |
15 log.info("<<<<< TOTAL TIME: %f <<<<<" % total) | 18 log.info("<<<<< TOTAL TIME: %f <<<<<" % total) |