Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

SbrTrace and ScriptTraceLevel

 

You can use the script trace feature to set line-by-line debugging of your script as it executes. A script trace is a block of program status information written to the Steel-Belted Radius Carrier server log file before the execution of a JavaScript statement. Information in each script trace frame includes:

  • The name of the .jsi or .aut file in which the script is defined

  • The current line number

  • The text of the JavaScript statement at that line number

  • Listings of selected program variable values

  • Listings of selected RADIUS attribute values (for LDAP scripts only)

You define the names of program variables and RADIUS attributes to be displayed in script traces by entering them in the [ScriptTrace] section of the JavaScript initialization file. For more details, see [ScriptTrace] Section.

You have two options to enable tracing of your scripts.

  • Manual tracing—You can set the ScriptTraceLevel parameter in the [Settings] section of the script file to 1 and call the SbrTrace() function from within your script. This causes a single script trace frame to appear in the log from the point in your script where the SbrTrace() function was called.

  • Automatic tracing—You can set the ScriptTraceLevel parameter in the [Settings] section of the script file to 2 to enable automatic tracing. In this mode, a script trace is performed every time that a JavaScript statement is executed by your script.

    Note

    Enabling script tracing for a single script file has a performance impact on all scripts running on Steel-Belted Radius Carrier, whether or not script tracing is enabled for those files. For this reason and because of large volume of log information produced, the use of script tracing is not recommended for production environments.

This example lists a small script and a portion of the automatic script trace generated from it.

Traces are produced just before execution of the JavaScript statement referenced in the trace. For example, the value of variable a is not reflected in the trace on line 1, but appears in the trace on line 2, after the assignment statement has executed. If a variable or attribute has not yet been assigned, or if a variable is out of scope at the time of the trace, the value is displayed in the log as <not found>.

Note

The attr keyword is supported only for LDAP authentication scripts. If this example is configured as a realm selection or attribute filter script, the attr = User-Name entry in the [ScriptTrace] section is ignored.

Script traces appear in the log if the server log level is greater than or equal to the trace log level. The server log level is determined by the LogLevel parameter of the [Configuration] section in radius.ini. The trace log level is determined by the LogLevel parameter in the [Settings] section of the script file. For more information, see [Settings] Section.

You can also use the optional LogLevel argument to specify the log level explicitly in the call to SbrTrace():

In this example, the argument trace appears unconditionally in the server log regardless of the script file LogLevel setting.

For more information about the SbrTrace function, see Logging and Diagnostic Methods. For more information about the server LogLevel setting, see the radius.ini file in the SBR Carrier Reference Guide.