lr_set_debug_message

Changes the message level for the script execution.

int lr_set_debug_message( unsigned int message_level_flag, unsigned int on_off );
Alphabetical Listing - C Language Utility Functions

Arguments

NameComments
message_level_flagOne of the Message Log Runtime Settings.
on_offA 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.

Conditions where function does not write to the log
FunctionDoes not write to log unless there is an error if:
lr_debug_message

The lr_debug_message invocation's message_level argument is not equal to the message level in effect
or
LR_MSG_CLASS_DISABLE_LOG is set

lr_log_message

LR_MSG_CLASS_BRIEF_LOG and LR_MSG_CLASS_EXTENDED_LOG are both cleared
or
LR_MSG_CLASS_DISABLE_LOG is set

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: lr.set_debug_message

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.");