XDCscript - Capsule-Object.$trace

From RTSC-Pedia

Jump to: navigation, search
revision tip
—— LANDSCAPE orientation
[printable version]  [offline version]offline version generated on 18-Nov-2017 00:11 UTC

XDCscript - Capsule-Object.$trace

Print a trace message

Contents

Synopsis

 
this.$trace(msg [, level, [groups]]);

Parameters

msg 
message string to output if trace for the current capsule is enabled.
level 
this optional integer value specifies the trace "level" of this statement; msg will only be output if the trace level requested is greater than or equal to the level.
groups 
this optional array of strings identifies the trace groups to which this statement belongs; msg will only be displayed if one or more of the specified trace group names listed in the groups array have been enabled.

Description

The string msg is output if trace is enabled for this capsule. The only required argument is msg. Default value for level is 0, and if groups is left unspecified, the trace statement will belong only to the group all, which contains all trace statements. Level 0 is the least verbose, while larger values generally provide more information.

Trace is enabled via xdc.traceEnable().

Example

Suppose the package pkgA contains the file package.xs with the following content:

package.xs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function init()
{
    $trace("init ...");
}
 
function close()
{
    $trace("closing ...", 0, ["pkgClose"]);
}
 
function validate()
{
    $trace("validating ...", 1, ["pkgValidate"]);
}

The configuration script

app.cfg
 
 
var Trace = xdc.module("xdc.services.global.Trace");
Trace.packageEnable(["pkgA"]);

or the command line

 
% xdc XDC_TRACE_PACKAGES="pkgA"

generates the following trace output:

 
 
TIME=10:36:46.730 AM -- C:/rep/pkgA/package.xs: init ... (pkgInit, all)
TIME=10:36:46.860 AM -- C:/rep/pkgA/package.xs: closing ... (pkgClose, all)

Notice that the output does not show output from the validate() function. This is because the trace level passed to $trace() is 1 and the default trace level is 0. In this example, to see output from all $trace statements you must also set the trace level to 1 (or more). For example, the command line:

 
% xdc XDC_TRACE_PACKAGES="pkgA" XDC_TRACE_LEVEL=1

generates the following trace output:

 
 
 
TIME=10:43:36.804 AM -- C:/rep/pkgA/package.xs: init ... (pkgInit, all)
TIME=10:43:36.934 AM -- C:/rep/pkgA/package.xs: closing ... (pkgClose, all)
TIME=10:43:37.555 AM -- C:/rep/pkgA/package.xs: validating ... (pkgValidate, all)

See also

XDCscript - Capsule-Object.$traceQuery Query whether capsule trace is enabled
XDCscript - xdc.traceEnable Enable debug trace output
Trace Support Tracing the execution of XDCscript

[printable version]  [offline version]offline version generated on 18-Nov-2017 00:11 UTC
Copyright © 2008 The Eclipse Foundation. All Rights Reserved
Personal tools
package reference