If you decide to use the
CGI file debug trace facilities,
you may find usefull some Mel's service program
functions that allow your CGI's to write
their own specific pieces of information
to this file.
The following procedures are available for use
in your CGI programs (use opcode callp to invoke them:
- isdebug
returns a 1-char value to indicate whether debugging is
on ('1') or off ('0').
- wrtdebug
writes into the debugging physical file,
CGIDEBUG,
the text passed to it as a parameter.
WRTDEBUG
is used by several of the service program's
subprocedures. You can use it, as desired.
No output is generated unless debugging output has been
turned on by the CGIDEBUG *ON command
or the optional parameter, force, has been set to *ON.
- wrtjobdbg
writes the qualified job name, current date, and current time
into the debugging file.
- wrtpsds
receives the program status data area and unconditionally writes it
in a formatted manner into the debugging file.
- SetNoDebug
turns off all conditionally or unconditionally debugging,
thus improving the performance of a CGI.
Examples
/copy mysrclib/qrpglesrc,hspecs
/copy mysrclib/qrpglesrc,hspecsbnd
 * Variables common to all CGIs
/copy mysrclib/qrpglesrc,prototypeb
/copy mysrclib/qrpglesrc,usec
/copy mysrclib/qrpglesrc,variables(1, or 2, or 3)
* ... etc. ...
* Example of using
* wrtdebug(text:force)
C callp wrtdebug(PgmName +
C ' execution time (seconds) ' +
C %trim(%editw(sec:' 0 . ')):*on)
* Example of writing qualified job name to debug file.
* Note that the force parameter is set to *on
C callp wrtjobdbg(*on)
&nspp;* Example of sending psds data to cgidebug physical file
C callp wrtpsds(psds) |
|
|
|
In your CGI programs you may use a
program status data structure and a
program status subroutine
to trap program status error and to
- notify the client user that an error has occurred
- use function wrtpsds
to format and write the contents of the
program status data structure
to the CGIDEBUG file.
See how this is implemented in program
CGIDEV2/TEMPLATE.
F infsr(*pssr)
* Prototype definitions and standard system API error structure
/copy cgidev2/qrpglesrc,prototypeb
/copy cgidev2/qrpglesrc,usec
*
* For program status data structure and program status subroutine
D psds sds
D psdsdata 429
D pssrswitch s 1 inz(*off)
D wrotetop s 1 inz(*off)
*
****************************************************************************
* Program status subroutine
****************************************************************************
C *pssr begsr
* If have already been in pssr, get out to avoid looping
C if pssrswitch=*on
C eval *inlr = *on
C return
C endif
* Set on switch to indicate we've been here
C eval pssrswitch=*on
* Write HTML sections (top if not already done, pssr, and *fini)
C if wrotetop=*off
C callp wrtsection('top')
C endif
C callp wrtsection('pssr endhtml *fini')
* Send psds data to cgidebug physical file
C callp wrtpsds(psds)
C eval *inlr = *on
C return
C endsr |
|
|
|