Tornado API Reference : Target Server Internal Routines
bkendlog - back-end debug log library
bkendLog( ) - log a request exchanged between the target server back end and the target
This library provides a routine to log the requests and the data exchanged between the target server and the target agent. Log output is sent to a file or device.
Use this routine when you write a new target server back end to log the data that is sent and received by the target server back end when the back-end debug option is ON.
The back-end logging facility is turned OFF by default. It can be turned on with the -Bd option to the target server. For example, under UNIX, log the back-end data to a console with:
% tgtsvr target -Bd /dev/ttyThe log file contains a header followed by the requests issued by the target server. The header gives information about the target server user, the start date and time of the log, the target server name, the target name, the target server options, and host informations. It also gives the back-end timeout value and the maximum number of retries in case of failure.The following is an example of a log message header:
User Name : philm Started : Wed Feb 28 14:35:09 1998 Target Server Name : RueDuQuai@scorff Target Name : kerpc Target Server Options : tgtsvr kerpc -n RueDuQuai -V -Bd backend.log Host : HP-UX scorff B.10.20 A 9000/777 Timeout value : 1 second(s) Request re-send Max : 3Each request is written to the log file with its sequence number, its name, the name of the input structure (labeled "In"), the value of the input structure, the name of the output structure (labeled "Out"), and its value.Example 1: WDB_TARGET_CONNECT request with sequence number 1 (first request issued) and no retries (0). This request has no input parameter and the output is a WDB_TGT_INFO structure.
1 WDB_TARGET_CONNECT Wed Feb 28 14:35:10 1998 0 Out status: Ok WDB_TGT_INFO WDB_AGENT_INFO agentVersion 2.0 mtu 1500 mode WDB_MODE_TASK WDB_RT_INFO rtType WDB_RT_VXWORKS rtVersion 5.3 cpuType 82 hasFpp 1 hasWriteProtect 1 pageSize 4096 endian 4321 bspName PC 486 bootline scorff:/folk/tornado/target/config/pc486/vxWorks memBase 0x0 memSize 0x7ff000 numRegions 0 hostPoolBase 0x7a3c0c hostPoolSize 0x40000Example 2: WDB_MEM_WRITE request with sequence number 25 and no retries. The input parameter is WDB_MEM_XFER structure and the output is an integer giving the status of the request.25 WDB_MEM_WRITE Wed Feb 28 14:36:11 1998 In WDB_MEM_XFER numBytes 4 destination 0x17d144 source 0x4000e930 0 Out status: OkFor the definitions of the structures exchanged between the target server and the target, see the file $WIND_BASE/share/src/agents/wdb/wdb.h.
When creating a new back end on a Windows host, the developer creates a new project under MicroSoft C++. It is necessary to go to the Link tab under the Settings menu of Project and add the required object/library modules manually. Adding /Tornado/host/x86-win32/lib/backend.lib provides the logging function and /Tornado/host/x86-win32/lib/libwpwr.lib provides the WTX APIs.
On average, 100 characters are used to log one request. When written to a file, the back end transaction data can quickly reach hundreds of kilobytes and fill a disk partition.
bkendlib.h
bkendlog, API Programmer's Guide: Target Server Back End
bkendLog( ) - log a request exchanged between the target server back end and the target
void bkendLog ( u_long procNum, /* procedure number to perform */ u_int xmit, /* request xmit: TRUE or FALSE */ char * args, /* Input/Output structure pointer */ int timeoutNb, /* timeout number */ int sequenceNumber, /* sequence number */ u_int status /* request status */ )
This routine logs request data exchanged between the target server back end and the target agent. Call this routine twice when issuing a WDB service request: once prior to sending the request, in order to log the request name and the input structure; and once on the reply, in order to log the output structure.
The log is written to the file specified with the -Bd option to tgtsvr. For example,
tgtsvr target -Bd /tmp/target.logWhen the -Bd option is not used, bkendLog( ) does nothing and returns immediately.The procNum argument contains the WDB request number sent to the target agent. If xmit is equal to TRUE, the structure pointed to by args is a transmission structure (labeled In in the log output); otherwise, it is a receive structure (labeled Out in the log output). timeoutNb contains the number of time an identical request was resent. sequenceNumber contains the request's current sequence number. If args is NONE, no input or output structure value is logged.
Now, the banner is finished to be printed by rpcCoreInit. To do that, procNum is equal to 0, and xmit is set to the value of the timeout, and status to resemd. The timeoutVal and resendMax arguments handle the time out value used by the back end and the maximum number of times a request might be resent to the target agent. These two back end features might be useless for some back end but are always logged in the file. The wdbLogMaxSize argument is the maximum size for the log file.
The code below gives an example of how to call bkendLog( ).
... /* increment the sequence number */ seqNumber++ ; /* log the WDB request */ bkendLog (procNum, TRUE, in, 0, (int ) seqNumber, 0); /* call the agent request */ do { status = myBackendCall (...); } while (++resendCnt < maxNumResend); /* log the structure returned by the target agent */ bkendLog (procNum, FALSE, out, resendCnt, 0, status); ...
N/A