Changeset - 1fb97030b9b7
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-04-01 16:35:03
marcin@python-works.com
let timerproxy use logging module
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/timerproxy.py
Show inline comments
 
from sqlalchemy.interfaces import ConnectionProxy
 
import time
 
from sqlalchemy import log
 
import logging
 
log = logging.getLogger('timerproxy')
 

	
 
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
 

	
 
def color_sql(sql):
 
@@ -13,16 +15,14 @@ class TimerProxy(ConnectionProxy):
 

	
 
    def __init__(self):
 
        super(TimerProxy, self).__init__()
 
        self.logging_name = 'timerProxy'
 
        self.log = log.instance_logger(self, True)
 

	
 
    def cursor_execute(self, execute, cursor, statement, parameters,
 
                       context, executemany):
 

	
 
        now = time.time()
 
        try:
 
            self.log.info(color_sql(">>>>> STARTING QUERY >>>>>"))
 
            log.info(color_sql(">>>>> STARTING QUERY >>>>>"))
 
            return execute(cursor, statement, parameters, context)
 
        finally:
 
            total = time.time() - now
 
            self.log.info(color_sql("<<<<< TOTAL TIME: %f <<<<<" % total))
 
            log.info(color_sql("<<<<< TOTAL TIME: %f <<<<<" % total))
0 comments (0 inline, 0 general)