root/galaxy-central/lib/galaxy/model/orm/logging_connection_proxy.py

リビジョン 2, 0.9 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1import time
2import inspect
3import os
4
5from galaxy.model.orm import *
6
7import logging
8
9log = logging.getLogger( __name__ )
10
11wd = os.getcwd()
12def stripwd( s ):
13    if s.startswith( wd ):
14        return s[len(wd):]
15    return s
16
17def pretty_stack():
18    rval = []
19    for frame, fname, line, funcname, _, _ in inspect.stack()[2:]:
20        rval.append( "%s:%s@%d" % ( stripwd( fname ), funcname, line ) )
21    return " > ".join( rval )
22
23class LoggingProxy(ConnectionProxy):
24    def cursor_execute(self, execute, cursor, statement, parameters, context, executemany):
25        start = time.clock()
26        rval = execute(cursor, statement, parameters, context)
27        duration = time.clock() - start
28        log.debug( "statement: %r parameters: %r executemany: %r duration: %r stack: %r",
29                   statement, parameters, executemany, duration, pretty_stack() )
30        return rval
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。