Skip to main content
GameDev.net gamedev.net
🔒 Locked

unbuffered HTML logfile output

Started by Baraclese May 31, 2003 at 4:02 PM 2 replies 650+ views
Original Post
Baraclese
Baraclese
Hi, I''m writing a logger to log debug messages, etc. its output is in HTML format. I want to use an overloaded insertion operator and the unitbuf manipulator to flush the bytes to the file everytime. I need to be able to jump from place to place in the file to write stuff there, but using the insertion operator would simply overwrite bytes in the file instead of copying the bytes around to fit new bytes in between. What''s a good way to achieve that? 1) Reading the bytes from the file that occur after the insertion point, then inserting the new ones and writing the other bytes to the end again doesn''t sound like a good idea once the logfile gets too big (several MB). Then again I could split the logfile up after it reaches a specific size. 2) Another solution I thought about was to leave an excact copy of the whole file in memory all the time and the insertion operator would perform insertions on the memoryfile and the file on the disk, this would save me one read operation on the diskfile and replace it with a copy and write operation on the memory file - RAM-size is no issue. Again this could be coupled with splitting the file into several parts (not all of the files are going to be written to and could be locked). What do you think? joni the shmups creators board @
Alan Kemp
Alan Kemp
Why do you need to jump around so much? Surely a log file is sequential, you write events one after the other as they occur?

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Baraclese
Baraclese
It basically is, it just depends on how much data you''re creating and how you''re going to visualize it. I could simply log it sequentially and then use a tool to convert it into a neat html file with tables and all, but that''s the inconvenient solution

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.