Monday, April 2, 2012

How to make debugging simpler

Most of the time, we need to know the data that is being transmitted to and back from the server in the Replay Log to troubleshoot the scripts. And what we usually do, is to configure the settings in the Runtime Settings through the following options:
  • Parameter substitution
  • Advance Trace
  • Data Returned by Server
By doing this, there will be a tremendous amount of logging data being captured in the Replay Log. And sometimes, it’s overwhelming and redundant… And at times, the error could just be reduced to a small area of the script and you to go through the entire script to reach the log entry that is useful to you. Or you have to spend ineffective time waiting for the entire script to complete while it builds the big chunk of logging data during replay.
Let’s make things a lot more simpler… we just want to view the data when the error occurs on certain API calls and reduce the amount of data generated to the Replay Log. How do we do it? We can use the lr_set_debug_message to display only a certain portion of the log generated. What lr_set_debug_message does is to set the message level for the script execution during runtime.
Place the lr_set_debug_message before the codes that you want the replay log to receive and close it again as per your requirement. The syntax is as followed and more information can be consulted in the
Action()
{
// Turn on Extended Log logging for “Data returned by server”, “Parameter substitution” and “Advanced Trace”
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_RESULT_DATA | LR_MSG_CLASS_PARAMETERS | LR_MSG_CLASS_FULL_TRACE,LR_SWITCH_ON);
/*
…. Actions …
*/
// Turning off the Extended Log for all settings
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_RESULT_DATA | LR_MSG_CLASS_PARAMETERS | LR_MSG_CLASS_FULL_TRACE,LR_SWITCH_OFF);
}

As you can see from the above example, it is possible to mix and match the combinations of the message_level (i.e. LR_MSG_EXTENDED_LOG) with other message_levels in the API to suit your needs. Below is the relation of the message_level with the actual settings found from the GUI itself.

Generic Logging Settings

LR_MSG_CLASS_DISABLE_LOG Flag for unchecking Enable Logging in the Runtime settings.
LR_MSG_CLASS_BRIEF_LOG Flag for Standard Log
LR_MSG_CLASS_EXTENDED_LOG Flag for Extended Log

Additional Settings for Extended logs

LR_MSG_CLASS_RESULT_DATA Flag for Data returned by server.
LR_MSG_CLASS_PARAMETERS Flag for Parameter substitution.
LR_MSG_CLASS_FULL_TRACE Flag for Advanced Trace.

Log Options

LR_MSG_CLASS_JIT_LOG_ON_ERROR Only on error. Which messages sent on error depends on other settings; relates to “Send messages only when an error occurs”.

No comments:

Post a Comment