Share this page

# lr.set_debug_message

Sets the message level for the script execution.

## JavaScript

    function lr.set_debug_message(  message_level, on_off  )

## VBScript

    Function lr.set_debug_message(  message_level, on_off  )

Message Functions

## Arguments

Name | Comments
--- | ---
message_level | 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 sets the debug message level, message_lvl, for the script execution. By setting a message level, you determine which information is sent. The setting is enabled by passing LR_SWITCH_ON as on_off, and disabled with LR_SWITCH_OFF.

The messages are sent to the log or Vuser output.

Message levels are generally set in the script's Runtime Settings dialog box. The value can be changed from the current runtime settings value. For example, if the script's current message level in the runtime settings is set at "Brief" mode, the value can be increased to "Extended log" (LR_MSG_CLASS_EXTENDED_LOG):

lr.set_debug_message(LR_MSG_CLASS_EXTENDED_LOG, LR_SWITCH_ON)

and later decreased to "Brief" once again:

lr.set_debug_message(LR_MSG_CLASS_EXTENDED_LOG,LR_SWITCH_OFF)

To enable logging that is disabled in the runtime settings, set the message level to another level. For example:

lr.set_debug_message (lr.MSG_CLASS_EXTENDED_LOG, lr.SWITCH_ON)

After enabling the logging, return to the disabled state by setting the debug level to zero (0) and activating the option using the lr.SWITCH_ON switch as the second parameter.

The message levels Result Data, Parameter Substitution, and Full Trace, are specific details, or sub-settings, of the Extended log setting. To set one of these sub-settings you can use logical Or's in your message_level argument.

Using LR_SWITCH_DEFAULT as on_off sets the on/off status of message_level to the default value regardless of previous calls to lr.set_debug_message. Use LR_SWITCH_DEFAULT with a single message_level argument. It does not work with ORed message_level settings.

## Return Values

Returns 0 on success and -1 on failure.

## Parameterization

Standard parameterization is not available for this function.

## VBScript Example

The following example illustrates the use of the debug_message functions. The initial message level setting is lr.MSG_CLASS_BRIEF_LOG. After two calls to lr.set_debug_message, the setting is the ORed value of lr.MSG_CLASS_BRIEF_LOG, lr.MSG_CLASS_EXTENDED_LOG, and lr.MSG_CLASS_RESULT_DATA, which is 19.The values are retrieved for display with lr.get_debug_message. Then, lr.debug_message is called with several message level values to illustrate when there is output.

To help understand the example, refer to the table showing the decimal values of the message level constants and their bit masks.

Constant | Value | Mask
--- | --- | ---
lr.MSG_CLASS_BRIEF_LOG | 1 | 00001
lr.MSG_CLASS_EXTENDED_LOG | 16 | 10000
lr.MSG_CLASS_PARAMETERS | 4 | 00100
lr.MSG_CLASS_RESULT_DATA | 2 | 00010
lr.MSG_CLASS_FULL_TRACE | 8 | 01000
lr.MSG_CLASS_RESULT_DATA | lr.MSG_CLASS_FULL_TRACE | 10 | 01010

    lr.message "Initial Log level is " + CStr(lr.get_debug_message)

    ' Initial Log level is 1
    lr.set_debug_message lr.MSG_CLASS_EXTENDED_LOG, 1
    lr.message "Extended Log level is " + CStr(lr.get_debug_message)

    ' Extended Log level is 17
    lr.set_debug_message lr.MSG_CLASS_EXTENDED_LOG Or lr.MSG_CLASS_RESULT_DATA , 1

    lr.message "Extended with Results Log level is " + CStr(lr.get_debug_message)

    'Extended with Results Log level is 19
    ' Call to any function or API
    ' emulated with random number.
    ' Return code over 2000 means the call failed.

    Randomize
    rc = Rnd * 4000
    lr.message "Return code = " + Cstr(rc)
    ' Return code = 3713.669

    if (rc>2000) then
    lr.debug_message lr.MSG_CLASS_BRIEF_LOG , _
    	"Operation failed with basic logging."

    ' Output: Operation failed with basic logging.

    lr.debug_message lr.MSG_CLASS_EXTENDED_LOG, _
    	"Operation failed with extended logging."

    ' Output: Operation failed with extended logging.

    lr.debug_message lr.MSG_CLASS_PARAMETERS , _
    	"Operation failed with parameter substitution logging."

    ' --- No output.

    `lr.MSG_CLASS_PARAMETERS AND Current level:
    ` 00100 AND 10011 = 0

    lr.debug_message lr.MSG_CLASS_RESULT_DATA , _
    	"Operation failed with result data logging."

    ' Output: Operation failed with result data logging.

    lr.debug_message lr.MSG_CLASS_FULL_TRACE , _
    	"Operation failed with full trace logging."

    ' --- No output
    `lr.MSG_CLASS_FULL_TRACE AND Current level:
    `01000 AND 10011 = 0

    lr.debug_message lr.MSG_CLASS_RESULT_DATA Or _
    	 lr.MSG_CLASS_FULL_TRACE , _
    	"Operation failed with either result data or full trace logging."

    ' Output: Operation failed with either result data or full trace logging.
    ` Full trace is not active, but Result data is, so this call outputs
    ` the message
    end if

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: