Browse Source

use notify for exceptionLogged output

Darren Ranalli 17 years ago
parent
commit
f40c53c0fc
1 changed files with 10 additions and 3 deletions
  1. 10 3
      direct/src/showbase/PythonUtil.py

+ 10 - 3
direct/src/showbase/PythonUtil.py

@@ -3009,6 +3009,8 @@ def superFlattenShip(ship):
     #PHASE 5: flatten strong!
     #PHASE 5: flatten strong!
     return ship.flattenStrong()
     return ship.flattenStrong()
 
 
+exceptionLoggedNotify = None
+
 def exceptionLogged(append=True):
 def exceptionLogged(append=True):
     """decorator that outputs the function name and all arguments
     """decorator that outputs the function name and all arguments
     if an exception passes back through the stack frame
     if an exception passes back through the stack frame
@@ -3031,12 +3033,16 @@ def exceptionLogged(append=True):
         return nullDecorator
         return nullDecorator
     
     
     def _decoratorFunc(f, append=append):
     def _decoratorFunc(f, append=append):
+        global exceptionLoggedNotify
+        if exceptionLoggedNotify is None:
+            from direct.directnotify.DirectNotifyGlobal import directNotify
+            exceptionLoggedNotify = directNotify.newCategory("ExceptionLogged")
         def _exceptionLogged(*args, **kArgs):
         def _exceptionLogged(*args, **kArgs):
             try:
             try:
                 return f(*args, **kArgs)
                 return f(*args, **kArgs)
             except Exception, e:
             except Exception, e:
                 try:
                 try:
-                    s = 'STACK UNWIND: %s(' % f.func_name
+                    s = '%s(' % f.func_name
                     for arg in args:
                     for arg in args:
                         s += '%s, ' % arg
                         s += '%s, ' % arg
                     for key, value in kArgs.items():
                     for key, value in kArgs.items():
@@ -3047,9 +3053,10 @@ def exceptionLogged(append=True):
                     if append:
                     if append:
                         appendStr(e, '\n%s' % s)
                         appendStr(e, '\n%s' % s)
                     else:
                     else:
-                        print s
+                        exceptionLoggedNotify.info(s)
                 except:
                 except:
-                    print 'exceptionLogged(%s): ERROR IN PRINTING' % f.func_name
+                    exceptionLoggedNotify.info(
+                        '%s: ERROR IN PRINTING' % f.func_name)
                 raise
                 raise
         _exceptionLogged.__doc__ = f.__doc__
         _exceptionLogged.__doc__ = f.__doc__
         return _exceptionLogged
         return _exceptionLogged