| Back in the mainframe Cobol days when you wanted to debug a program you
added print statements to your code which displayed short notes about the contents of
variables or which part of the program was currently executing, this is a long lost skill
killed by a new breed of interactive debugging tools that let you step in/out and
generally shake it all about. This is great when you are working in a homogeneous
environment such as PowerBuilder but when you start working in a distributed heterogeneous
environment the debugger will do you no favours. I have been working a lot with Active
Server talking to PowerBuilder objects and of course to expose my PowerBuilder interface
to COM I have to build a set of run time libraries which are registered using PBComReg.
While these objects tend to be simple interfaces to PowerBuilder proxies there is still
a small amount of logic processing in the interface especially in the custom state
manager. Debugging these objects requires a blast from the past. Thus I present gf_writelog()
the ultimate debugging tool.
I use gf_writelog to write log entries to a simple text file on the root C:\ Drive of
the web server. NOTE it must be the C:\ drive as your object will not have rights to
the network drive when it runs under the web server.
I have two versions of the function, one takes a simple string and is good for
debugging simple objects, and a second version which take a pointer to the class to
retrieve the classname for the more complicated multiple object scenarios.
The source code is listed below:
gf_write_log( string as_Val )
Long ll_FN
ll_FN = FileOpen( 'c:\ken.txt', LineMode!, Write!, &
LockWrite!, Append! )
FileWrite( ll_FN, String( Now() ) + ' ' + as_Val )
FileClose( ll_FN )
gf_write_log( powerobject apo_PO, string as_Val )
Long ll_FN
ll_FN = FileOpen( 'c:\ken.txt', LineMode!, Write!, &
LockWrite!, Append! )
FileWrite( ll_FN, String( Now() ) + ' ' + &
apo_PO.ClassName() + ' ' + as_Val )
FileClose( ll_FN )
|