Forum Discussion
Hi Marsha,
Sorry, Doesn't work that way either.
Thanks a lot for suggestions. Hoping to find solution!
You could always use your own function to switch which log method gets called. Something like this:
function TestMe() { WriteLog("message", 2); WriteLog("anything", 5); WriteLog("error", 1); } function WriteLog(message, type) { switch (type) { case 1: Log.Error(message); break; case 2: Log.Message(message); break; default: Log.Warning(message); break; } }
- Marsha_R10 years agoChampion Level 3
What Joseph outlined is what I was trying to explain. Can you give us some more details as to why this won't work for you?
- Vivek7210 years agoContributor
Thanks Joseph and Marsha. Sorry for not being elaborate on my previous reply. What I actually meant was although I am aware of creating my own function and use it as suggested by you I wasn't happy to include one function in another as I wanted the log type to be used in function I created which already had couple of other functions within, which required me to give number of inputs. Now inserting another function for log type would add to that confusion in terms of maintenance. So I wanted some simple one liner eg., x = Log.Checkpoint(data found), y = Log.Error(data not found). Whereas if I am using function for log type my script goes like
e.g., function apply filter(browsername, input1, input2, input3,.......... input10, logtype1, logtype2,logtype3,logtype4,msg1,msg2,msg3,msg4). So, I wanted to reduce hassle passing those number of input values. But, anyhow I have now sorted that out and decided to reduce log types to avoid complexity so I can use the function as was suggested.
Thanks a lot for brilliant response,time and helping hand.
- HKosova10 years agoSmartBear Alumni (Retired)
If you use JScript, you can do this:
function Test() { var MESSAGE_TYPE = "Message"; // or "Error", "Warning", "Event", "Checkpoint" Log[MESSAGE_TYPE]("test"); MESSAGE_TYPE = "Warning"; Log[MESSAGE_TYPE]("test"); }
Will this work for you?
Related Content
- 3 years agoMarkSchofer
- 11 months agorhu
Recent Discussions
- 2 hours agoSvetaG