views:

30

answers:

1

We have a c++ application (console) that runs on windows and unix. This application used output files to output verbose log files of system calls/prints/etc. The prblem is, that in certain occasion we might get signal 11/2 after new features are added.

Now whenever, that happenes, we do not get 'almost complete' information from log files to track down the origin of the bug/problem since the output files are not closed properly when signal 11 occurs. (it's only partial or zero sized)

We considered adding a flush command after every fprintf line print. Q :

  1. Is that considered a good practive ?
  2. does fflush works well on windows platfrom ?
  3. any thoughts/other methods to keep log files while system might crash unexpectedly ?
+1  A: 

You need to send the log data not to the file, but to some external logging application which you can create in 30 minutes. Sending of output is possible via socket or via pipes or using SendMessage() Windows API ( if you target Windows ).

Eugene Mayevski 'EldoS Corp