I play with Boost.Log in boost 1.54.0 to make sure this is a viable option for my application. In general, I have no problems with buffering, so I don’t want to include auto_flush or anything else ... but I noticed that messages that are logged before I call fork()
are duplicated, and I wonder if this comes from due to buffering, the buffer is duplicated when copying the process image, and then both processes eventually write their copies of the buffer to the log file ...
Basically, I would just like to do a manual flash log entry, only once, before I call fork()
to make sure there are no messages in my memory. In other words, I'm looking for something similar to the fflush()
, .flush()
, << flush
, and so that I can use to boost the magazine.
I tried using << flush
with the log, but I still get duplicate messages, so I'm not 100% sure if it turns red and the duplicates are caused by some other problem or if it somehow ignores << flush
...
Edit:
I looked around and found that the booster magazine is not safe for the plug. Therefore, I must add that I am not trying to use the same log in the parent and child processes. I have two branching scenarios - in one of them the parent terminates immediately and the child contineus (so it should be safe), and in the other case the child has to open its own separate log file so that it is also safe ... but I ' d you need to figure out how to close the log file, and then open a new one (in another file). I believe closing a sink might also be a way to force a flush ...?
source
share