Show More
@@ -1,6 +1,8 b'' | |||||
1 | from sqlalchemy.interfaces import ConnectionProxy |
|
1 | from sqlalchemy.interfaces import ConnectionProxy | |
2 | import time |
|
2 | import time | |
3 | from sqlalchemy import log |
|
3 | import logging | |
|
4 | log = logging.getLogger('timerproxy') | |||
|
5 | ||||
4 | BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38) |
|
6 | BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38) | |
5 |
|
7 | |||
6 | def color_sql(sql): |
|
8 | def color_sql(sql): | |
@@ -13,16 +15,14 b' class TimerProxy(ConnectionProxy):' | |||||
13 |
|
15 | |||
14 | def __init__(self): |
|
16 | def __init__(self): | |
15 | super(TimerProxy, self).__init__() |
|
17 | super(TimerProxy, self).__init__() | |
16 | self.logging_name = 'timerProxy' |
|
|||
17 | self.log = log.instance_logger(self, True) |
|
|||
18 |
|
18 | |||
19 | def cursor_execute(self, execute, cursor, statement, parameters, |
|
19 | def cursor_execute(self, execute, cursor, statement, parameters, | |
20 | context, executemany): |
|
20 | context, executemany): | |
21 |
|
21 | |||
22 | now = time.time() |
|
22 | now = time.time() | |
23 | try: |
|
23 | try: | |
24 |
|
|
24 | log.info(color_sql(">>>>> STARTING QUERY >>>>>")) | |
25 | return execute(cursor, statement, parameters, context) |
|
25 | return execute(cursor, statement, parameters, context) | |
26 | finally: |
|
26 | finally: | |
27 | total = time.time() - now |
|
27 | total = time.time() - now | |
28 |
|
|
28 | log.info(color_sql("<<<<< TOTAL TIME: %f <<<<<" % total)) |
General Comments 0
You need to be logged in to leave comments.
Login now