lr.debug_message

Sends a debug message to the log file.

int lr.debug_message( int message_level, String message );
Message FunctionsJava Syntax

Arguments

NameComments
message_level One of the Message Log Runtime Settings. Disabled does not apply.
format A formatted string which is the message to be sent to the log file. You may use the standard Message Formatting that is available for printf.

The lr.debug_message function sends a debug message when the specified message level is active. If the specified message level is not active, a message is not issued. You can set the active message level to MSG_CLASS_BRIEF_LOG or MSG_CLASS_EXTENDED_LOG from the user interface or by using lr.set_debug_message. To determine the current level, use lr.get_debug_message.

Note that you can also specify multiple message levels with an OR separator ("|"). If any one of the levels are active, the message is issued to the Output window.

The message is sent to the output window. To display the debug messages in the output window or log file, use the Expert Mode Settings. Activate Expert Mode (Tools > Expert Mode) and then choose Tools > Options > Debug Information and select the General check box.

lr.set_debug_message calls can affect the output.

Return Values

This function returns the number of characters written, not including the terminating null-character. On error, it returns a negative value.

Parameterization

You cannot use standard parameterization for any arguments in this function.

Example

In the following example, the lr.debug_message function assigns a message to a full trace log. Since this log level was set by lr.set_debug_message, the message appears in the log.

The second call to set_debug_message resets the message level to its former value.

//Add the following to the beginning of the file:

import java.lang.* ;
import java.io.* ;
// Set the extended and full trace log options.
    lr.set_debug_message(lr.MSG_CLASS_EXTENDED_LOG |lr.MSG_CLASS_FULL_TRACE, lr.SWITCH_ON);
    PrintStream outstr;
    try {
     File file = new File("c:/temp/Java" + Thread.currentThread() + ".txt");     
     FileOutputStream fos = new FileOutputStream(file.getName());
     outstr = new PrintStream(fos);
    }
     catch (IOException e) {
          outstr = null;
// lr.debug_message Sends a debug message to the Output window.
// Send a message only when the message level is set to Full Trace 
      lr.debug_message (lr.MSG_CLASS_FULL_TRACE, "Exception occurred" );
      outstr.println("Init (vuser " + lr.get_vuser_id() + ")");
      lr.set_debug_message(lr.MSG_CLASS_EXTENDED_LOG |lr.MSG_CLASS_FULL_TRACE, lr.SWITCH_OFF);
}