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
Error log location
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
Re: Error log location
Rob,
Please implement this function in your main PRG and set the desired path:
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
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
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
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.
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.
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
Re: Error log location
Dear Robb,
From FWH\samples\buildh64.bat
link @msvc.tmp /nologo /subsystem:windows /force:multiple
Yes, I agree with you, we are going to implement those functions as you have suggested![Smile :-)](./images/smilies/icon_smile.gif)
From FWH\samples\buildh64.bat
link @msvc.tmp /nologo /subsystem:windows /force:multiple
Yes, I agree with you, we are going to implement those functions as you have suggested
![Smile :-)](./images/smilies/icon_smile.gif)