The DPRINTF macro
The DPRINTF macro directly marks a tracepoint in the code. It formats a trace message and specifies the threshold for the tracepoint.
DPRINTF(trace_class, threshold, (format [, arg]...));
- trace_class
- Either a trace-class name or the trace-class identifier (an integer value) expressed as a character string.
- threshold
- A non-negative integer that sets the tracepoint threshold for execution.
- format
- A printf-style output format that formats the trace message and can include print formatting directives.
- arg
- An expression to be evaluated for output. It provides the value for a print formatting directive in the format argument.
The DataBlade API also provides the GL_DPRINTF macro for formatting internationalized trace messages. For more information, see the HCL Informix® GLS User's Guide.
result = doAbigPiece(x, "x location");
DPRINTF("funcEntry", 50,
("After calling doAbigPiece with x = %d and %s \
result = %f", x, "x location", result));
The trace message consists of the literal text, the print formatting directives, and the expressions for the print formatting directives.
SELECT classid FROM informix.systraceclasses
WHERE name = 'funcEntry';
result = doAbigPiece(x, "x location");
DPRINTF("42", 50,
("After calling doAbigPiece with x = %d and %s \
result = %f", x, "x location", result));
The tracepoint threshold determines which tracepoints generate output, based on the current trace levels of the trace class. If a tracepoint threshold is not greater than the current trace level, the database server writes the associated trace message to the trace-output file.
- Trace level = 0
No tracing occurs.
- Trace level > 0
Any tracepoint with a threshold greater than zero (0) prints. All others do not.
Tracing level | Threshold values | Sample DPRINTF call |
---|---|---|
None | 0 | None |
Light | 1 to 10 | DPRINTF("funcEntry", 1, ("Entering doTheJob: the main function")); |
Medium | 11 to 20 | DPRINTF("funcEntry", 11, ("Entering doAbigPiece: a top-level \help function")); |
Heavy | >= 20 | DPRINTF("funcEntry", 21, ("Entering doAlittlePiece: an often-called \helper")); |
The maximum number of trace levels is the largest non-negative integer representable on the platform.