Trace blocks
In some cases, you might need to perform some computations before you decide whether to output certain trace data. To perform computations for a tracepoint, define a trace block.
A trace block initially compares a specified threshold with the current trace level to determine whether to continue with the trace computations. Within the trace block, it can output a result in a trace message.
- The tf() function acts as a threshold check
that determines whether to execute a particular trace block.
The syntax of the tf() function is as follows:
tf(trace_class, threshold)
This function returns a Boolean result; it is TRUE if the current trace level of the trace_class class is greater than or equal to the threshold.
- The tflev() function returns the current
trace level of the specified trace class.
The syntax of the tflev() function is as follows:
tflev(trace_class)
This function returns an integer result that is the current trace level of the trace_class class.
- The tprintf() function outputs a trace message
but does not require the threshold argument.
The syntax of the tprintf() function is as follows:
tprintf(format [,arg]...)
The format and arg arguments are the same as those in the DPRINTF macro.
The DataBlade API also provides the gl_tprintf() function for formatting internationalized trace messages within a trace block. For more information aboutgl_tprintf(), see the HCL Informix® GLS User's Guide.
/* Compare current trace level of "chck_consist" class and
* with a tracepoint threshold of 20. Continue execution of
* trace block if trace level >= 20
*/
if( tf("chck_consist", 20) )
{
x = fastScan(aList, y);
consFactor = checkRconsit(x, bList);
/* Generate trace message (in US English) */
tprintf("...in doWork: x = %f and consFactor = %f",
x, consFactor);
}