|
@@ -128,7 +128,7 @@ class StackTrace:
|
|
|
r = ''
|
|
r = ''
|
|
|
comma = ','
|
|
comma = ','
|
|
|
for filename, lineNum, funcName, text in self.trace:
|
|
for filename, lineNum, funcName, text in self.trace:
|
|
|
- r += '%s.%s:%s%s' % (filename[filename.rfind('\\')+1:], funcName, lineNum, comma)
|
|
|
|
|
|
|
+ r += '%s.%s:%s%s' % (filename[:filename.rfind('.py')][filename.rfind('\\')+1:], funcName, lineNum, comma)
|
|
|
if len(r):
|
|
if len(r):
|
|
|
r = r[:-len(comma)]
|
|
r = r[:-len(comma)]
|
|
|
return r
|
|
return r
|
|
@@ -2496,6 +2496,22 @@ def exceptionLogged(f):
|
|
|
_exceptionLogged.__doc__ = f.__doc__
|
|
_exceptionLogged.__doc__ = f.__doc__
|
|
|
return _exceptionLogged
|
|
return _exceptionLogged
|
|
|
|
|
|
|
|
|
|
+# class 'decorator' that records the stack at the time of creation
|
|
|
|
|
+# be careful with this, it creates a StackTrace, and that can take a
|
|
|
|
|
+# lot of CPU
|
|
|
|
|
+def recordCreationStack(cls):
|
|
|
|
|
+ if not hasattr(cls, '__init__'):
|
|
|
|
|
+ raise 'recordCreationStack: class \'%s\' must define __init__' % cls.__name__
|
|
|
|
|
+ cls.__moved_init__ = cls.__init__
|
|
|
|
|
+ def __recordCreationStack_init__(self, *args, **kArgs):
|
|
|
|
|
+ self._creationStackTrace = StackTrace()
|
|
|
|
|
+ return self.__moved_init__(*args, **kArgs)
|
|
|
|
|
+ def getCreationStackTrace(self):
|
|
|
|
|
+ return self._creationStackTrace
|
|
|
|
|
+ cls.__init__ = __recordCreationStack_init__
|
|
|
|
|
+ cls.getCreationStackTrace = getCreationStackTrace
|
|
|
|
|
+ return cls
|
|
|
|
|
+
|
|
|
import __builtin__
|
|
import __builtin__
|
|
|
__builtin__.Functor = Functor
|
|
__builtin__.Functor = Functor
|
|
|
__builtin__.Stack = Stack
|
|
__builtin__.Stack = Stack
|