Page 1 of 1

How to change the default error file filename.

PostPosted: Tue Aug 09, 2011 6:59 pm
by HunterEC
Guys:

How can I rename the default filename for the error log (Error.log) during program execution ?


Thank you.

Re: How to change the default error file filename.

PostPosted: Tue Aug 09, 2011 7:26 pm
by Gale FORd
Here is what I do for error and trace log files.
cLogFile := gete('username')
Set( _SET_ERRORLOG, cLogFile+'_diwin.err' )
Set( _SET_TRACEFILE, cLogFile+'_diwin.log' )

You can also do the following for the error log file.
Set errorlog to filename

Re: How to change the default error file filename.

PostPosted: Wed Aug 17, 2011 8:11 am
by MarcoBoschi
Code: Select all  Expand view
#include "fivewin.ch"
FUNCTION MAIN()

SET ERRORLOG TO myerrorfile.log

USE nothing

RETURN NIL

This program goes in error and produce error.log not myerrorfile.log
King regards
marco

Re: How to change the default error file filename.

PostPosted: Wed Aug 17, 2011 4:54 pm
by nageswaragunupudi
FW provides for setting path to write error.log file, but does not provide for a different name for error.log file.

We may set a different folder where the error.log is written by calling function SetErrorPath( cNewPath ) --> cOldPath.

cNewPath should end with "\".

Error.log file will be written in cNewPath + "Error.log"

Re: How to change the default error file filename.

PostPosted: Wed Aug 17, 2011 9:34 pm
by Gale FORd
I use xHarbour commercial so it may support the error log filename.
This is from the documentation.

Syntax
SET ERRORLOG TO <cLogFile> [ADDITIVE]

Arguments
<cLogFile>
This is the name of the file that stores information about runtime errors. The default file is named "Error.log"
ADDITIVE
If this option is specified, new error information is appended to the log file. Otherwise, <cLogFile> is overwritten when a new error occurs. Description
The SET ERRORLOG command is used in customized error handling routines where error information about runtime errors is written to a user-defined file. By default, runtime error information is stored in the Error.log file.

Re: How to change the default error file filename.

PostPosted: Sat Aug 20, 2011 2:31 pm
by James Bott
Hunter,

The filename is hardcoded in errsysw.prg. You can just change it there and compile and add the OBJ to your link script. I have done this in the past. Actually, I modified it to create a new sequential filename for each new error so I could review all the errors that an app had generated. You could even set it up to email the error file to you.

We might suggest to Antonio that it would be nice to have a SetErrorFilename() function similar to the existing SetErrorPath() function. Then we wouldn't have to modify the source. This wouldn't, however, allow you to have incremental filenames. This would be another nice feature that could be turned on with just a flag.

Regards,
James

Re: How to change the default error file filename.

PostPosted: Sat Aug 20, 2011 5:31 pm
by nageswaragunupudi
We might suggest to Antonio that it would be nice to have a SetErrorFilename() function similar to the existing SetErrorPath() function.

Good suggestion.

Re: How to change the default error file filename.

PostPosted: Sat Aug 20, 2011 6:47 pm
by MarcoBoschi
:D

Re: How to change the default error file filename.

PostPosted: Sun Aug 21, 2011 7:49 am
by Antonio Linares
* New: functrion SetErrorFileName( <cNewFileName> ) --> cOldFileName lets you assign and retrieve
the filename used to save the error log information.

Implemented for next FWH build :-)

Re: How to change the default error file filename.

PostPosted: Sun Aug 21, 2011 11:17 am
by nageswaragunupudi
You could even set it up to email the error file to you.


It is easy to set up any action with the generated error.log file, including email the file, without modifying the errorsysw.prg.

We can set up a posterror action codeblock with this function

SetPostErrorAction( { |cErrorLogFileName, oError| MyAction( cErrorLogFileName, oError ) } ) --> PreviousBlock

We can implement email functionality or any other action within function MyAction( ... )

Re: How to change the default error file filename.

PostPosted: Mon Aug 22, 2011 4:09 am
by HunterEC
Antonio & Rao:

Great discussion. Good to know that it will be implemented. Thank you to all you guys who posted on this thread.