I have recently been doing some work that has been quite in depth,
i was wondering what you think is better for logging.
Is it better to.
A. Every time i want to write to my log, open the file, write to it
then close it straight away so it there is no real chance of losing
information in the case of a critical failure or crash.
B. Save periodically, maybe after every major section has been finished
meaning i can narrow downs where the errors are.
Any other suggestions??
I don’t want to be opening and saving all day with the large volume of text
i need to record, but i don’t want to lose my granularity of the information.
I am writing in C++, sorry for not mentioning it prior.
To my knowledge, it’s fairly common (mandated?) for a stream flush to be the equivalent to saving.
That is, when you say:
Everything waiting to be written is written. Note that
std::endl;also callsflush. So, leave it open and just flush after a dump of information.