The following page talks about how to get a timestamp from javascript:
https://tecadmin.net/get-current-date-time-javascript/#:~:text=Current%20Time%20in%20JavaScript,%3Ai%3As%E2%80%9D%20format.&text=2-,var%20today%20%3D%20new%20Date()%3B,)%20%2B%20%22%3A%22%20%2B%20today
Once you have the date in the format you want, then you can do something like the following:
var fileOutput = ogscript.createFileOutput("log3.txt", true);
var date = new Date();
var message = date.getHours() +":" + date.getMinutes() + ":" + date.getSeconds() + " message"
fileOutput.writeString(message + "\n");
fileOutput.close();
If you are writing very frequently (like a few times a second), you probably don't want to open and close the file every time. You could open the file when the panel loads, and then close it when the panel closes.
#DashBoard