Page 1 of 1
Error log location
Posted: Thu Jun 24, 2021 5:48 pm
by rhlawek
I have an app, call it appname.exe, which has a font release error in it that results in a file named appname.log being written to the same folder as the executable, with contents such as this:
2021/06/24 13:37:37: EXCESS RELEASE OF FONT ARIAL[ hFont : 0] ( nCount : -1 )
<-TFONT:END(0) <-TBUTTON:DESTROY(0) <-TWINDOW:HANDLEEVENT(0) <-TBUTTON:HANDLEEVENT(0) <-_FWH(0) <-SENDMESSAGE(0) <-(b)TWINDOW(0) <-TMDICLIENT:SENDMSG(0) <-TMDICLIENT:CHILDCLOSE(0)
Fixing the error is simple, that's not my question, what I want to know is how do I redirect appname.log so that it writes to a folder of my choosing, and not in the default location alongside the executable itself?
Robb
Re: Error log location
Posted: Thu Jun 24, 2021 7:40 pm
by Antonio Linares
Rob,
Please implement this function in your main PRG and set the desired path:
Code: Select all | Expand
function LogFile( cFileName, aInfo, lDate )
local cMyPath := ".\"
local hFile, cLine := "", n
DEFAULT lDate := .T.
if lDate
cLine := DToC( Date() ) + " " + Time() + ": "
endif
if ValType( aInfo ) != "A"
aInfo = { aInfo }
endif
for n = 1 to Len( aInfo )
cLine += cValToChar( aInfo[ n ] ) + Chr( 9 )
next
cLine += CRLF
if ! File( cMyPath + cFileName )
FClose( FCreate( cMyPath + cFileName ) )
endif
if( ( hFile := FOpen( cMyPath + cFileName, FO_WRITE ) ) != -1 )
FSeek( hFile, 0, FS_END )
FWrite( hFile, cLine, Len( cLine ) )
FClose( hFile )
endif
return nil
Re: Error log location
Posted: Thu Jun 24, 2021 11:25 pm
by rhlawek
Thank you Antonio, overriding the library function will work.
I already use these functions in my code to override other default logs locations for FWH apps:
SetErrorPath( cLogDir )
SetErrorFileName( "error.log" )
What I will do in my local copy of LogFile, instead of modifying the path this way:
local cMyPath := ".\"
I will instead modify it this way:
local cMyPath := SetErrorPath()
This way it will pick up the static path already being set with the call SetErrorPath( cLogDir )
This might be a change to consider making in the fivewin code.
Thanks again.
Robb
Re: Error log location
Posted: Fri Jun 25, 2021 3:21 pm
by rhlawek
Antonio,
How can I avoid the issue of the linker complaining that LogFile() already exists in a fivewin library? I'm used to having local code just supercede the library functions when there is a name conflict, but I haven't figured out how to get the linker to ignore this particular conflict.
Re: Error log location
Posted: Fri Jun 25, 2021 4:53 pm
by Antonio Linares
Dear Robb,
From FWH\samples\buildh64.bat
link @msvc.tmp /nologo /subsystem:windows
/force:multipleYes, I agree with you, we are going to implement those functions as you have suggested
