I am trying to append to a log file, using HTML tables format for each incident. However, there is one difficulty which I am not sure how to solve. Here's a static output of the HTML
<table>
<tr><td> .... </td>
</tr>
<!-- new log entry should enter here -->
</table>
</html>
The question is how I can quickly insert log entries into the table quickly without messing up the HTML, preferably using the least amount of processing? I know I can load in the entire file, use a templating solution, and rewrite the file but that may be slow (the log files could grow fast quickly!).
So I am looking for the usual open file for append, and somehow write after the last row, but before the tag.
Any suggestions?
PS. I know most browser would render the HMTL if I leave out the tag at the end, but I am curious to see if there could be an ideal solution.