VMware Cloud Community
mayank_goyal
Enthusiast
Enthusiast

Tip: Using vRO LogMarker

What’s LogMarker?

It’s an inbuilt method System.setLogMarker() in vRO which adds a additional payload to all the logs/warnings/errors/debugs following it. So it can be easily used in your Workflows’ Scriptable tasks, actions and even at other places. Let’s see a quick demo.

 

 

Implementation for Scriptable tasks

Just add this line of code in at the top of your scriptable task:

System.setLogMarker(“SCRIPT: “+System.currentWorkflowItem().getDisplayName());

 

 

 

 

 

System.setLogMarker("SCRIPT: "+System.currentWorkflowItem().getDisplayName());
System.log("Performing tasks...");
System.log("Task 1 completed");
System.debug("Subtask 1a completed");
System.warn("Task 1 completed with some errors");

 

 

 

 

 

image-16.png

 

 

Implementation for Direct Actions (drag & drop)

Just add this line of code at the top of your action:

if(arguments.callee.name.substr(6)) System.setLogMarker(“ACTION: “+arguments.callee.name.substr(6));

Updated: try{ System.setLogMarker("ACTION: " +arguments.callee.name.substr(6)); } catch(e){};

 

 

 

 

 

try{ System.setLogMarker("ACTION: " +arguments.callee.name.substr(6)); } catch(e){};
System.log("Performing tasks in action...");
System.log("Task 2 completed");
System.debug("Subtask 2a completed");
System.warn("Task 3 completed with some errors");
System.error("Task 4 failed");

 

 

 

 

image-17.png

 

 

Implementation for inline Actions (called inside a scriptable task)

The scope of logMarker seems to be at function level (direct actions and scriptable tasks are converted into functions by vRO Executor). Hence, if an action which is called inline is using setLogMarker() then, marker will remain set to what was set by action even after it start executing the rest of the code in scriptable task.

So to fix that, you can just set the logMarker again for the scriptable task as you can see here in line 5.

image-19.jpg

 

With these 3 simple rules, I think you can quite improve your workflow logs with minimal efforts and just using built-in method.

 

Advantages:

  • There is no need to import custom code every time.
  • You can still use System.log() instead of using the custom log.log();
  • Probably faster.


-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
Tags (1)
7 Replies
StefanSchnell
Enthusiast
Enthusiast

Hello @mayank_goyal,

thank you very much for sharing.

A tiny question: I tried this approach with version 8.5.1.18666 and it seems that it doesn't work with any version of Aria Automation.

StefanSchnell_0-1680240391865.png

Error Message: Action 'testStefan001' in module 'de.stschnell' failed: Wrapped java.lang.ClassCastException: class ch.dunes.scripting.jsmodel.Definitions$2 cannot be cast to class ch.dunes.scripting.server.script.MainScriptingObject (ch.dunes.scripting.jsmodel.Definitions$2 and ch.dunes.scripting.server.script.MainScriptingObject are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @19132c01) (de.stschnell/testStefan001#2)

StefanSchnell_1-1680240671479.png

Unfortunately I could not find anything in the release notes about that. With which version did you realize this approach?

Thanks and best regards
Stefan

 


More interesting information at blog.stschnell.de

0 Kudos
mayank_goyal
Enthusiast
Enthusiast

When I wrote the blog, I used vRO 8.6.2. Today, I even tested it on 8.11.2 (21452458) and it works fine.

mayank_goyal_0-1680260134365.png

 



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
SakshiGupta
Contributor
Contributor

Hi,

I was also getting the same error, it seems this does not work when trying to execute action directly but it works when we try to call the action from workflow.

It is the same as it was for "System.setLogMarker(arguments.callee.name.substr(6))". This was also not working and giving the same error.

SakshiGupta_3-1681278801025.png

 

So now there are two points as per my conclusion

  1. arguments.callee.name.substr(6) returns null when we try to run an action directly, but works when an action is called inside the action.
  2. System.setLogMarker() does not work when we try to execute an action directly. Also it does not work when the action is being called inside the action.

Both of them will work when action is called inside the workflow, and as of now I am not able set the log marker when executing actions separately.

SOLUTION : To be able to use them from workflow without any failure.

For first case:

if(arguments.callee.name.substr(6))

{

    try{

        System.setLogMarker("ACTION: " +arguments.callee.name.substr(6));

    }

    catch(e){}

}

 

For second case:

 

try{

     System.setLogMarker("ACTION: test2");

}

catch(e){}

 

SakshiGupta_2-1681278728052.png

 

SakshiGupta_1-1681278688386.png

 

 

 

 

 

mayank_goyal
Enthusiast
Enthusiast

Thanks @SakshiGupta.

Attaching screenshots that uses Sakshi's suggestion and testify using actions with logMarker both in other actions as well as Workflow Scriptable tasks without any ParallelExecution error and not only that but also identifies the exact action markers as you see in the logs.

 



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
0 Kudos
StefanSchnell
Enthusiast
Enthusiast

Excellent, thank you very much @SakshiGupta for sharing this.


More interesting information at blog.stschnell.de

0 Kudos
bsaxe
VMware Employee
VMware Employee


@SakshiGupta wrote:

 

  1. arguments.callee.name.substr(6) returns null when we try to run an action directly, but works when an action is called inside the action.
  2. System.setLogMarker() does not work when we try to execute an action directly. Also it does not work when the action is being called inside the action.

 What do you mean by "Also it does not work when the action is being called inside the action?"

0 Kudos
mayank_goyal
Enthusiast
Enthusiast

What Sakshi mean to say is that when 2 actions (actionA & actionB) both used setLogMarker() and actionA called actionB inline then it failed with Parallel Execution error. However, handling that inside try & catch block kind of makes this whole approach very usable.



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
0 Kudos