lr.set_debug_message
Changes the message level for the script execution.
int lr.set_debug_message( int message_level_flag, int on_off);
| Message Functions | Java Syntax |
Arguments
| Name | Comments |
|---|---|
| message_level_flag | One of the Message Log Runtime Settings. |
| on_off | A switch to activate or deactivate a specific message level setting. Use one of the On-Off Constants. |
The lr.set_debug_message function changes the debug message level bitmap. By setting or clearing flags in the bitmap, you determine which information is sent by calls to lr.message, lr.log_message, lr.output_message and lr.debug_message. A flag is set by passing lr.SWITCH_ON as the argument for parameter on_off. A flag is cleared by passing lr.SWITCH_OFF.
The message level is initially set in the script's Runtime Settings dialog box. lr.set_debug_message changes the message level from the current value. Each call to lr.set_debug_message sets or clears the flag or flags specified in the call. A call does not change other flags that have been set or cleared. Therefore, the message level in effect is the result of the runtime settings and all previous calls to lr.set_debug_message.
Regardless of the message level, if an error is logged or the script calls lr.error_message, recent messages are written to the log. For example, if a message is sent with lr.output_message while only lr.MSG_CLASS_JIT_LOG_ON_ERROR is set, that message is not output. However, if there is an error shortly after the lr.output_message call, that message is output along with the error message.
| Function | Does not write to log unless there is an error if: |
|---|---|
| lr.debug_message | The lr.debug_message invocation's |
| lr.log_message | lr.MSG_CLASS_BRIEF_LOG and lr.MSG_CLASS_EXTENDED_LOG are both cleared
|
| lr.message | Only lr.MSG_CLASS_JIT_LOG_ON_ERROR is set (All other flags are cleared) |
| lr.output_message | Only lr.MSG_CLASS_JIT_LOG_ON_ERROR is set (All other flags are cleared) |
Return Values
Returns 0 on success and -1 on failure.
Parameterization
You cannot use standard parameterization for any arguments in this function.
Example
Example 1 - Set trace option
In the following example, the lr.set_debug_message function sets the full trace option. The function assigns a message to a full trace log. Since this log level was set, the message will appear 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. The full trace option is ORed with the extended log option. */
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 log 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);
}
Example 2 - Disabling messages
In this example, the lr.set_debug_message function disables lr.message and lr.output_message from writing to the log unless an error occurred.
int n = lr.get_debug_message(); // get the current log level
lr.output_message("The current level is " + n); // this message is written to the log
lr.set_debug_message(lr.MSG_CLASS_BRIEF_LOG | lr.MSG_CLASS_EXTENDED_LOG , lr.SWITCH_OFF); // clear all flags
lr.set_debug_message(lr.MSG_CLASS_JIT_LOG_ON_ERROR, lr.SWITCH_ON); // set the log level to JIT
// After the above two calls, lr.MSG_CLASS_JIT_LOG_ON_ERROR && FFFF = lr.MSG_CLASS_JIT_LOG_ON_ERROR.
lr.output_message("This output message is not written to log");
lr.message("This output message is not written to log");
// If an error is output automatically or lr.error_message is called,
// recent messages that were blocked are then logged.
// The recent messages are logged no matter what message level is in effect.
// lr.error_message("The messages from lr.output_message and lr.message are logged with this message.");

