Trees | Indices | Help |
---|
|
1 ''' 2 Extra utilities for vtrace 3 ''' 4 # Copyright (C) 2007 Invisigoth - See LICENSE file for details 5 6 import vtrace 7 import vtrace.notifiers as v_notifiers 8 import vtrace.rmi as v_rmi 911 """ 12 A trace-manager is a utility class to extend from when you may be dealing 13 with multiple tracer objects. It allows for persistant mode settings and 14 persistent metadata as well as bundling a DistributedNotifier. You may also 15 extend from this to get auto-magic remote stuff for your managed traces. 16 """8118 self.trace = trace 19 self.dnotif = v_notifiers.DistributedNotifier() 20 self.modes = {} # See docs for trace modes 21 self.metadata = {} # Like traces, but persistant2224 """ 25 Set all the modes/meta/notifiers in this trace for management 26 by this TraceManager. 27 """ 28 self.trace = trace 29 if vtrace.remote: 30 trace.registerNotifier(vtrace.NOTIFY_ALL, v_rmi.getCallbackProxy(trace, self.dnotif)) 31 else: 32 trace.registerNotifier(vtrace.NOTIFY_ALL, self.dnotif) 33 34 for name,val in self.modes.items(): 35 trace.setMode(name, val) 36 37 for name,val in self.metadata.items(): 38 trace.setMeta(name, val)3941 """ 42 Untie this trace manager from the trace. 43 """ 44 if vtrace.remote: 45 trace.deregisterNotifier(vtrace.NOTIFY_ALL, v_rmi.getCallbackProxy(trace, self.dnotif)) 46 else: 47 trace.deregisterNotifier(vtrace.NOTIFY_ALL, self.dnotif)48 5355 if self.trace != None: 56 return self.trace.getMode(name, default) 57 return self.modes.get(name, default)58 6365 if self.trace != None: 66 return self.trace.getMeta(name, default) 67 return self.metadata.get(name, default)6870 self.dnotif.registerNotifier(event, notif)7173 self.dnotif.deregisterNotifier(event, notif)7476 """ 77 Deliver a local event to the DistributedNotifier managing 78 the traces. (used to locally bump notifiers) 79 """ 80 self.dnotif.notify(event, trace)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Nov 16 18:22:29 2012 | http://epydoc.sourceforge.net |