Changeset 1728
- Timestamp:
- Feb 17, 2014, 11:10:18 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/logfm2.cmd (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/logfm2.cmd
r1599 r1728 5 5 * 6 6 * Change log: 7 * 11 Jul 17 JBS Corrected redirection syntax 7 * 17 Jul 11 JBS Corrected redirection syntax 8 * 17 Feb 14 JBS Ticket 512: Improvements 9 * Enhanced error-handling 10 * No log file parameter defaults to fm2.log 11 * Checks for write-ability of the log file and prompts for action if unwritable 12 * Other improvements 13 * All logs are written to the <fm2dir>\debug\logfiles directory 14 * (so they are easy to find and do not clutter other directories) 15 * Headers and footers are written to the log file to aid in interpreting 16 * the contents 17 * When FM/2 closes the log file is opened 8 18 * 9 19 */ 10 20 21 /* Determine and ensure existence of log file directory */ 22 parse source . . thispgm 23 logfiledir = filespec('D', thispgm) || filespec('P', thispgm) || 'LogFiles' 24 call SysMkDir logfiledir 25 26 /* Process parameter, using default if none is passed. */ 11 27 parse arg logfile 12 fulllogfilename = stream(logfile, 'c', 'query exists') 13 if fulllogfilename = '' then 14 fulllogfilename = logfile 15 call lineout fulllogfilename, date() time() 'Logging started...' 16 call directory '..' 17 'start fm3.exe 1>>'fulllogfilename '2>&1' 28 logfile = strip(logfile) 29 if logfile = '' then 30 logfile = 'fm2.log' /* Default to "fm2.log" */ 31 32 /* Check "write-ablility" and set the full filename for the log file */ 33 do until logfile_ok = 1 34 fulllogfilename = logfiledir || '\' || filespec('N', logfile) 35 logfile_exists = (stream(fulllogfilename, 'c', 'query exists') \= '') 36 /* Check for locked file here */ 37 if stream(fulllogfilename, 'c', 'open write') = 'READY:' then 38 logfile_ok = 1 39 else 40 do 41 logfile_ok = 0 42 rc = stream(fulllogfilename, 'c', 'close') 43 say 'Unable to open existing log file:' logfile 44 say 45 say logfile 'may be locked by another process.' 46 say 47 say 'Please close any processes that may be using' logfile || '.' 48 say '(Another instance of a logged FM/2 or an editor perhaps?)' 49 say 50 say 'Just press the Enter key to retry' logfile || '.' 51 say 'Or type in a new log file name:' 52 newlogfile = strip(linein()) 53 if newlogfile \= '' then 54 logfile = newlogfile 55 end 56 end 57 58 /* Write "header" */ 59 if logfile_exists = 1 then 60 do 61 call lineout fulllogfilename, LinePrefix() 'Created log file:' fulllogfilename 62 /* Write "instructions" to file here? */ 63 end 64 call lineout fulllogfilename, LinePrefix() 'Logging started.' 65 call stream fulllogfilename, 'c', 'close' 66 67 /* Start FM/2 */ 68 call directory logfiledir || '\..\..' 69 'fm3.exe # 2>>' || fulllogfilename 70 71 /* Write "footer" */ 72 call lineout fulllogfilename, LinePrefix() 'Logging ended.' 73 call stream fulllogfilename, 'c', 'close' 74 75 /* Open log file for viewing */ 76 call SysSetObjectData fulllogfilename, 'OPEN=DEFAULT' 18 77 return 78 79 LinePrefix: procedure 80 return '###' date() time() 81
Note:
See TracChangeset
for help on using the changeset viewer.
