cbTRACE

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

cbTRACE

Return to chapter overview

The cbTRACE is a system-level callback that can be used to retrieve trace information. The trace string retrieved through the callback is the same as that which goes to the debug window via OutputDebugString.

This structure is used to return trace info to the callback:

typedef struct       // trace callback info

{

  TRACECat    eTraceCat;    // trace category

  UINT16      uTotalMsgLen; // total message length 

  CHAR        pszTrace[];   // trace string 

                            // (recommended size = DBIMAXTRACELEN (8192))

} TRACEDesc;

typedef enum         // trace categories

{

  traceUNKNOWN   = 0x0000, 

  traceQPREPARE  = 0x0001, // prepared query statements

  traceQEXECUTE  = 0x0002, // executed query statements

  traceERROR     = 0x0004, // vendor errors

  traceSTMT      = 0x0008, // statement ops (i.e. allocate, free)

  traceCONNECT   = 0x0010, // connect / disconnect

  traceTRANSACT  = 0x0020, // transaction

  traceBLOB      = 0x0040, // blob i/o

  traceMISC      = 0x0080, // misc.

  traceVENDOR    = 0x0100, // vendor calls

} TRACECat;

The TRACECat enums have the same bit sequence used to set the TRACE MODE configuration option, and can also be used (singularly or |'d together) as input to the dbTRACEMODE database property. The uTotalMsgLen field of the TRACEDesc struct can be used to determine whether the returned string (in pszTrace) has been truncated.

EXAMPLE of registering the cbTRACE callback:

DbiRegisterCallBack 

              (NULL, 

              cbTRACE, 

              iClientData, 

              sizeof (TRACEDesc) + DBIMAXTRACELEN,

              (pVOID)pTraceInfo,  // ptr to client-allocated TRACEDesc

              (pfDBICallBack) lpfnTrace);