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");
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");
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.
With these 3 simple rules, I think you can quite improve your workflow logs with minimal efforts and just using built-in method.
Advantages:
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.
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)
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
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.
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.
So now there are two points as per my conclusion
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){}
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.
Excellent, thank you very much @SakshiGupta for sharing this.
@SakshiGupta wrote:
- 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.
- 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?"
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.