Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
a13519 Contributor.
Contributor.
328 views

log config in java script (not javascript)

Hi, I feel there are very few resources for java script customization. I try to config the log during runtime in java script:

lr.set_debug_message(lr.MSG_CLASS_DISABLE_LOG, lr.MSG_OFF);

but it failed during compilation and throw  cannot find symbol [MsgId: MERR-22986]

anybody can help on this?

Thanks,

Song

0 Likes
3 Replies
Outstanding Contributor.. JHF Remmelzwaal Outstanding Contributor..
Outstanding Contributor..

Re: log config in java script (not javascript)

lr.MSG_OFF has to be lr.SWITCH_OFF

Check documentation (Function help). When you want to diable messages you have to use lr.SWITCH_ON. Check this code

lr.vuser_status_message("Debug start = %d", lr.get_debug_message());
lr.set_debug_message(lr.MSG_CLASS_DISABLE_LOG  , lr.SWITCH_OFF);
lr.vuser_status_message("Debug disable with off = %d", lr.get_debug_message());
lr.set_debug_message(lr.MSG_CLASS_DISABLE_LOG  , lr.SWITCH_ON);
lr.vuser_status_message("Debug disable with on = %d", lr.get_debug_message());
lr.set_debug_message(lr.MSG_CLASS_DISABLE_LOG  , lr.SWITCH_OFF);
lr.vuser_status_message("Debug disable with off = %d", lr.get_debug_message());

Note MSG_CLASS_DISABLE_LOG with SWITCH_OFF has no effect, because it's value does not represent a bit (and it does not restore the previous value, you have to do that yourself).

0 Likes
a13519 Contributor.
Contributor.

Re: log config in java script (not javascript)

Thanks for your information. 

It failed in compilation for the excerise code :

lr.vuser_status_message("Debug start = %d", lr.get_debug_message());
lr.set_debug_message(0  , lr.SWITCH_OFF);
lr.vuser_status_message("Debug disable with off = %d", lr.get_debug_message());
lr.set_debug_message(0  , lr.SWITCH_ON);
lr.vuser_status_message("Debug disable with on = %d", lr.get_debug_message());
lr.set_debug_message(0  , lr.SWITCH_OFF);
lr.vuser_status_message("Debug disable with off = %d", lr.get_debug_message());

it shows vuser_status_message can not be applied in given type. as you said 

lr.MSG_CLASS_DISABLE_LOG

 will stopped the compilation, seems VuGen can't recorgnize it in java script, I believe it works in C.

Thanks anyway.

0 Likes
Highlighted
Outstanding Contributor.. JHF Remmelzwaal Outstanding Contributor..
Outstanding Contributor..

Re: log config in java script (not javascript)

The example code was translated from C to Java by hand :-)

When I decompile ...\LoadRunner\classes\lrapi\lr.class, I do not see the static final value MSG_CLASS_DISABLE_LOG, but I see the other lr.MSG_CLASS* defines. So your approch to take the value 0  works. This is the correct working Java example (tested it this time) with my own define for MSG_CLASS_DISABLE_LOG:

 

public static final int MSG_CLASS_DISABLE_LOG = 0;
public int action() throws Throwable {
	lr.vuser_status_message("Debug start = "+ lr.get_debug_message());
	lr.set_debug_message(MSG_CLASS_DISABLE_LOG, lr.SWITCH_OFF);
	lr.vuser_status_message("Debug disable with off = "+ lr.get_debug_message());
	lr.set_debug_message(MSG_CLASS_DISABLE_LOG, lr.SWITCH_ON);
	lr.vuser_status_message("Debug disable with on = "+ lr.get_debug_message());
	lr.set_debug_message(MSG_CLASS_DISABLE_LOG, lr.SWITCH_OFF);
	lr.vuser_status_message("Debug disable with off = "+ lr.get_debug_message());
	return 0;
}//end of action

 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.