Thursday 28 November 2013

lr_set_debug_message() in Load Runner

lr_set_debug_message:
  • By using lr_set_debug_message() function we can manually set the log options in the vuser script
  • By using lr_set_debug_message() to dispaly only a certain portion of the log generated.
  • We can place the lr_set_debug_message before the code in Action() method and close as per requirement.

Ex:
Action()
{
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG, LR_SWITCH_ON);
------------------------------------------------------
-------------------------------------------------------
-----------------------------------------------------
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG, LR_SWITCH_OFF);
return 0;
}

Each logging option has separate  C-constant 
Log LevelC ConstantValueBinary Value
DisabledLR_MSG_CLASS_DISABLE_LOG000000000 00000000
BriefLR_MSG_CLASS_BRIEF_LOG100000000 00000001
Extended LogLR_MSG_CLASS_EXTENDED_LOG1600000000 00010000
Result DataLR_MSG_CLASS_RESULT_DATA200000000 00000010
Parameter SubstitutionLR_MSG_CLASS_PARAMETERS400000000 00000100
Full Run-Time TraceLR_MSG_CLASS_FULL_TRACE800000000 00001000
Log on ErrorLR_MSG_CLASS_JIT_LOG_ON_ERROR51200000010 00000000

NOTE:Before writing these functions in your script first to disable the log in runtime settings otherwise you can't ddifferentiate the log settings (click F4)

We can also write multiple parameters in lr_set_debug_message() function by separated using " | "

These constants are integer type variables and return type is unsigned int
By using these C constants we can set different log options

The lr_set_debug_message() is also written in function and palce the function inglobals.h and call those functions in Action() method

EX:(This code is in globals.h)
#ifndef _GLOBALS_H
#define _GLOBALS_H

//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"

//--------------------------------------------------------------------
// Global Variables

#endif // _GLOBALS_H

logs_on()
{
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG |LR_MSG_CLASS_RESULT_DATA| LR_MSG_CLASS_PARAMETERS , LR_SWITCH_ON );
}
logs_off()
{
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG |LR_MSG_CLASS_RESULT_DATA| LR_MSG_CLASS_PARAMETERS , LR_SWITCH_OFF );
}


call the above functions in Action() method

Action()
{
logs_on()
-----------------------
-----------------------
----------------------
logs_off()
return();
}