Mike Lewis said:
Use ADIR() to loop through the files; use FILETOSTR() and STRTOFILE() to read and write the contents into memory variables.
..and finally back to the files.
Both things have pros and cons
1. SET COVERAGE
a) pro: does not need any code changes than one line activating it and (optionally) one line deactivating it
b) pro: logs every line of code and is very detailed, including the time spent for each line of code executed, which is something you can't log with normal logging
c) con: logs every line of code and grows a large log file, which will need post processing as there's too much to just read through.
d) pro: You have a built in tool to process such coverage log files in Tools->Coverage Profiler (therefore the logs are not meant for human reading)
The last thing is also showing the reason it's called coverage logging. The intent is to find out whether a coverage testing of your code covers all code lines, i.e. your test cases go into each if and else branch or each case of a DOCASE...ENDCASE statement and the code coverage is thereful fully or not. It's not the only use of the log as another feature of the Coverage profile is computing the overall and average time spent on a line of code, too, so it's also for performance profiling.
2. DEBUGOUT or logging
a) con: you need to put in log calls into your code at every stage you'd like to see in your log file
b) pro: you can choose wherever and whatever to log, not only PROGRAM(), of course, you can log values of variables, you can also log timings as SECONDS() gives you a running up number of seconds since last midnight and there are more precise timestamps available with Windows API calls.
c) pro: you only log at points that interst you and get the concentrated log information you want.
d) pro: While you don't have a tool like Coverage Profiler the log files should tell you what you want to know without any postprocessing of the logged data.
In some cases 1 a) is a huge pro and in most cases the pros of 2b)-d) outweigh that. In your case, as you mainly want to know which programs run, coverage profiling is giving you that with one added line of code, though.
It works both in IDE and EXE. And Mike pointed out that DEBUGOUT only logs in the IDE while the debugger is open as an advantage. Well, often enough you actually want to know what was run by users, so when the EXE is used, that speaks for a logging.prg as you have it. On the other hand you can start or not start coverage logging checking _vfp.startmode, so you can also only log in the IDE in debug sessions and not in the EXE, if you want. I didn't mention that you can choose between logging to a text file or a dbf with your logging function - DEBUGOUT outputs into the debugout window of the debugger which can be saved to a text file. The text logs coverage generates are usable CSV, so you cna read them into a DBF, which means there's a balance of advantages/disadvantages about the file formats.
Chriss