mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
removed .py from compact StackTrace, added recordCreationStack
This commit is contained in:
parent
656b85eb8c
commit
14722c112b
@ -128,7 +128,7 @@ class StackTrace:
|
||||
r = ''
|
||||
comma = ','
|
||||
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):
|
||||
r = r[:-len(comma)]
|
||||
return r
|
||||
@ -2496,6 +2496,22 @@ def exceptionLogged(f):
|
||||
_exceptionLogged.__doc__ = f.__doc__
|
||||
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__
|
||||
__builtin__.Functor = Functor
|
||||
__builtin__.Stack = Stack
|
||||
|
Loading…
x
Reference in New Issue
Block a user