Example: lr.set_debug_message

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);
 }

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