For instance, say you got a program that keeps a log of the activities it performs. Does anyone have any idea on how to set a max size you would want that file to be? like say 1mb.
I was thinking maybe there is some way to load the pre-existing contents into an array of somekind and seeing how big it is, and then adding to the array throughout the runtime of the program then write it out when finished.. That way you could even reverse the order of the log, putting the newest entries at the top for easy viewing.
the only problem with that is I want to flush the buffer and write to the file after every logged action. That way if something goes wrong and crashes at least there is something in the log file.
Any ideas?
I was thinking maybe there is some way to load the pre-existing contents into an array of somekind and seeing how big it is, and then adding to the array throughout the runtime of the program then write it out when finished.. That way you could even reverse the order of the log, putting the newest entries at the top for easy viewing.
the only problem with that is I want to flush the buffer and write to the file after every logged action. That way if something goes wrong and crashes at least there is something in the log file.
Any ideas?