When using ppython.exe, my program works fine…but if I try ppythonw.exe (the windows version without console), it will crash after executing for a while.
So basically what I need now is to write out all the debug info from the console to a text file. I refered to the following link:
Right, that only dumps the Panda output. You can also get your print output to a file–maybe even the same file, if the filename is the same–with something like this:
For reasons I don’t understand, the system is fine if I replace a call to initLogging with the contents of the initLogging function. But if I call the function, it crashes.
I ran the following code and compared results:
import direct.directbase.DirectStart
from direct.showbase import DirectObject
from pandac.PandaModules import *
from direct.task import Task
from direct.actor import Actor
from direct.interval.IntervalGlobal import*
from direct.gui.DirectGui import *
loggingInitialized=0
def initLogging():
try:
nout = MultiplexStream()
print "Ptr is "+str(Notify.ptr())
Notify.ptr().setOstreamPtr(nout, 0)
nout.addFile(Filename("out.txt"))
loggingInitialized=1
except Exception, args:
print "Unable to multiplex Panda error stream."
print str(args)
if __name__=="__main__":
print "Ptr is "+str(Notify.ptr())
initLogging()
run()
If I replace the call to initLogging() with the contents of the initLogging function, the program starts and runs fine. If, however, I call initLogging (as I do above), the program crashes shortly after Notify.ptr().setOstreamPtr.
Any suggestions would be greatly appreciated!
-Mark