Put globalized trace messages into code
The DataBlade® API provides the tracing functions to insert globalized tracepoints into UDR code.
- The GL_DPRINTF macro formats a globalized trace message and specifies
the threshold for the tracepoint. The syntax for GL_DPRINTF is as
follows:
GL_DPRINTF(trace_class, threshold, (message_name [,toktype, val]...,MI_LIST_END));
- The gl_tprintf( ) function formats a globalized
trace message but does not specify a tracepoint threshold.The gl_tprintf( ) function is for use within a trace block, which uses the tf( ) function to compare a specified threshold with the current trace level. The syntax for gl_tprintf( ) is as follows:
gl_tprintf(message_name [,toktype ,val]..., MI_LIST_END);
- trace_class
- Either a trace-class name or the trace-class identifier integer value expressed as a character string.
- threshold
- A nonnegative integer that sets the tracepoint threshold for execution.
- message_name
- The identifier for a globalized message stored in the systracemsgs system catalog table of the database.
- toktype
- A string made up of a token name followed by a single percent (%) symbol followed by a single character output specifier as used in printf formats.
- val
- A value expression to be output that must match the type of the output specifier in the preceding token.
- MI_LIST_END
- A macro constant that ends the variable-length list.Important: The MI_LIST_END constant marks the end of the variable-length list. If you do not include MI_LIST_END, the user-defined routine might fail.
i = 6;
/* If the current trace level of the funcEntry class is greater
* than or equal to 20, find the version of the qp1_entry
* message whose locale matches the current database locale
*/
GL_DPRINTF("funcEntry", 20,
("qp1_entry",
"ident%s", "one",
"i%d", i,
MI_LIST_END));
13:21:51 Exiting msg number was one; the input is still 6
i = 6;
/* Compare current trace level of "funcEnd" class and
* with a tracepoint threshold of 25. Continue execution of
* trace block if trace level >= 25
*/
if ( tf("funcEnd", 25) )
{
i = doSomething();
/* Generate an internationalized trace message (based
* on current database locale) */
gl_tprintf("qp1_exit", "ident%s", "deux", "i%d", i,
MI_LIST_END);
}
13:21:53 Le numéro de message en sortie était deux; l'entrée est toujours 6
The database server writes the trace messages in the trace-output file in the code set of the locale associated with the message. If the trace message originated from the systracemsgs system catalog table, its characters are in the code set of the locale specified in the locale column of its systracemsgs entry. The database server might have performed code-set conversion on these trace messages if the code set in the UDR source is different from (but compatible with) the code set of the server-processing locale.