trace
Syntax
trace expression;
trace {
/* body */
}Description
Write a message to the trace file, if tracing is
enabled. If tracing is not enabled, trace output is not generated.
The trace message can be an XPath expression
or string, or it can be generated by the contents of a trace statement block.
Enabling of tracing is typically a feature of the environment
in which a SLAX script is called. When executing a script using the slaxproc command, include the --trace or -t option to enable tracing. For more information about slaxproc, see Understanding the SLAX Processor (slaxproc).
Attributes
trace expression |
XPath expression or string written to the trace file. |
SLAX Example
The following examples demonstrate the trace statement syntax. The first example writes a concatenated string
to the trace file. The second example uses a code block to output
a <max> element and a <min> element and the values of the max and min variables. The third example uses a conditional
statement to specify when to output trace data. If the expression
evaluates to true, the code block writes
the string and the <options> element
hierarchy to the trace file.
trace "max " _ $max _ "; min " _ $min;
trace {
<max> $max;
<min> $min;
}
trace {
if ($my-trace-flag) {
expr "max " _ $max _ "; min " _ $min;
copy-of options;
}
}Release Information
Statement introduced in version 1.1 of the SLAX language, which is supported in Junos OS Release 12.2 and later releases.