Dragonfly Q&A

LogManager is stopping halfway through

0 like 0 dislike
My LogManager is starting to print things, but then about halfway through the program, it stops, sometimes in the middle of a line. Why might it be doing this? UPDATE: If I tell it to flush(true) it doesn't do this. Do you suppose the print buffer is running out of space?
asked Sep 13, 2015 by Andrew
When you say "it doesn't do this" ... do you mean it doesn't stop printing in the middle of a line (i.e., it fixes the problem)?  Yes, I would expect doing a fflush() after each vfprintf() call would fix it. What I suspect is happening is that the buffer is in memory and not written to disk yet, but when your program exits (I assume it crashes) you lose the memory data.

If you are saying that fflush() does not fix the problem, then I don't really know.  I'd have to know more about what your code is doing. Does it only print part of a line consistently?  When?  Providing a scenario that can automatically produce the bug would be the first step.
It would always cut off in the middle of the same line when printing. The line was "df::ObjectList::addObject(): Failed! ObjectLis" on line 10018 in the logfile. Using the setFlush(true) fixed the problem. With setFlush(false), the program would terminate normally, but the LogManager would have stopped printing after this point. EDIT: That line is supposed to read "df::ObjectList::addObject(): Failed! ObjectList full!"
Ok, that sounds normal - the output from fprintf() (and similar functions) does not get flushed to disk unless explicitly told to do so or when the file is closed.  What is unusual is that you say your program terminates normally.  Does it close the file at that time?  I'm still assuming it either is not terminating normally and/or it is not closing the file, hence unwritten data in memory is not written to disk.  Other than that, I don't know and would need to look at your code more closely.

Please log in or register to answer this question.

More information about Dragonfly can be found on the Dragonfly Home Page.
...