how to check if a line exists in a logfile

Posted by Admin on 26-Feb-2009 21:51

i have got a logfile created like this:

output stream error-s to value(lc-pathdir + "import-errors-" +

string(today,"999999":u) + "-" + string(li-time /* ,"HH:MM:SS" */ ) +

".log"). /*creating the log file in the specified directory

with the time string in the file name*/

i would like to show an error alert box if any line is created in the logfile, otherwise a different alert box will be displayed...

so what function can be used to check if any line was created in the logfile...???

thanks...

All Replies

Posted by Simon de Kraa on 27-Feb-2009 00:00

Not sure what you are trying to accomplish but you can use a counter to check the number of messages written to the logfile or if you have to check the logfile from another program maybe you can use file-info:file-size to check the for file size > 0?

Posted by Thomas Mercer-Hursh on 27-Feb-2009 11:00

The tricky thing here could be where you have closed the file or not after writing the message. If you haven't, then buffered output may not have yet been written to disk. I would try file-info or seek, but it would be safer to make sure the file is closed first. Of course, my preferred approach would be to use another mechanism to record this state change, something internal to the application. E.g., I would put the logging code in a PP, SP, or object which was called whenever you needed to write to the log, but such object could also retain state without having to check the output file itself. You might get some ideas from http://www.oehive.org/ExceptionClass

This thread is closed