Cxbx-reloaded: Init Log Output To File is Not Fully Flushed

Created on 25 Aug 2019  路  2Comments  路  Source: Cxbx-Reloaded/Cxbx-Reloaded

When settings is set to default with kernel output log to a file. The initialize log does not output everything to the file unless enable the log filter to output more details. It has been reported by another tester by the way.

Apparently, we had not flushed the initialize log output to the file properly.

bug good-for-beginners help wanted

Most helpful comment

There is void setbuf(FILE *stream, char *buf); from stdio.h.

If stream is the log file, you can use setbuf(stream, NULL); to set the buffering mode to unbuffered. This should make all writes appear in the file, as soon as it is written to.

stderr is also unbuffered, by default. stdout is buffered & I set it to unbuffered via setbuf(stdout, NULL); at the beginning of main().

All 2 comments

An important detail on this, is that the log file appears to be missing the last few lines when emulation is terminated.
This might be because the log file isn't flushed when the process terminates, or perhaps the way we terminate prevents the flushing of buffered file writes. Either way, this makes it difficult to troubleshoot specific cases, especially when log filtering is active (that results in less logging, so a higher chance that important messages aren't written to disc).

There is void setbuf(FILE *stream, char *buf); from stdio.h.

If stream is the log file, you can use setbuf(stream, NULL); to set the buffering mode to unbuffered. This should make all writes appear in the file, as soon as it is written to.

stderr is also unbuffered, by default. stdout is buffered & I set it to unbuffered via setbuf(stdout, NULL); at the beginning of main().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PatrickvL picture PatrickvL  路  3Comments

LukeUsher picture LukeUsher  路  3Comments

PatrickvL picture PatrickvL  路  3Comments

PatrickvL picture PatrickvL  路  4Comments

PatrickvL picture PatrickvL  路  3Comments