trace

Enables logging a debug or trace message to the ScriptDebugTrace output. A message can also be output to the console or to the system logs.

Type and Usage

Parameters

Takes one required and two optional parameters:

  • The first parameter is the message which is output. The value can be one of the following:

    • A string. If the string is passed as the only parameter, the ScriptDebugTrace variable must be set for this function to execute. The string is added to the accumulated debug trace.

    • #local, which prepares a dump of all current local variables.

    • #all, which prepares a full HDA dump of all local data, result sets, and environment data.

  • The second (optional) parameter is the location where the message will be relayed. The values can be the following:

    • #console, to display to a console

    • #log to log a message in the HTML log files

    • the name of a variable (such as StatusMessage). In that case, the message is appended to the current value.

  • The third (optional) parameter is for the appropriate tracing section and is only relevant if the location parameter is set to #console.

Example

The following example logs the string message to the system console, which is always logged:

<$trace("message", "#console")$>

The following example logs the string message to the system console in the pagecreation tracing section.

<$trace("message", "#console", "pagecreation")$>

The following example logs the string message to the HTML Content Server log file.

<$trace("message", "#log")$>

The following example dumps all local variables and their values to the system console.

<$trace("#local", "#console")$>

The following example dumps all local variables, result sets, and environment variables to the system console.

<$trace("#all", "#console")$>

The following example dumps all data to the variable MyTraceDump, which can then be displayed on the page. This is useful for HCSP developers who may not have the appropriate access rights to view the console logs.

<$trace("#all", "MyTraceDump")$>
<$MyTraceDump$>

See Also