Exemple #1
0
class Tracer(BaseTracer):

    def __init__(self):
        self._db = DB("sqlite:///db.sqlite")
        self._depth = 0

    def on_call(self, frame, _):
        self._db.handle_call(time=datetime.now(),
                             module=__name__,
                             func_name=getframeinfo(frame).function,
                             from_class="",
                             depth=self._depth,
                             args=frame.f_locals)
                             
        #print "+" * self._depth, format_frame(frame), "arguments: ", ", ".join('{}={}'.format(k, v) for k, v in frame.f_locals.iteritems())
        self._depth += 1
        return self._trace # means trace everything under this scope
        
    def on_return(self, frame, arg): 
        self._depth -= 1
        #print "-" * self._depth,  format_frame(frame), "return: ", arg

    def __exit__(self, *e):
        super(Tracer, self).__exit__(*e)
        self._db.flush()
Exemple #2
0
 def __init__(self):
     self._db = DB("sqlite:///db.sqlite")
     self._depth = 0