Example: lr_set_debug_message

Enabling full trace

In this example, the lr_set_debug_message function enables the full trace option just before a call to lrd_fetch, which the user needs to debug because it has been giving unexpected results.

The second invocation of lr_set_debug_message resets the debug level to what it was formerly, by turning off (LR_SWITCH_OFF) the Extended message level.

rc = lrd_fetch(Csr1, 1, 1, 0, PrintRow3);
if (rc>2000) 
       "Fetch failed returned %d", rc);

/* Now reset message class to former level */ 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.

unsigned int n = lr_get_debug_message();         // get the current log level

lr_output_message("The current level is %d", n); // this message is written to the log

lr_set_debug_message(n, 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("%s", "This output message is not written to log");
// If an error is output by LoadRunner 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. 
//			"The messages from lr_output_message and lr_message are logged with this message.");