Action Logger
- Last UpdatedDec 13, 2023
- 2 minute read
The Action Logger is a component of the XR Instructor. It is used to register actions taken by application users.
This code is not part of the modules.
Configuring the Action Logger
The information to be registered can change depending on the project purpose and there can be some user actions to track. For example, when checking an instrument it could be interesting to also plot the displayed value. Augmented reality actions can be included or not in the log. See Log panel.
Code example
In the sample Virtual plant project, there is a sample implementation of the logger named logger.xml.
<patch name="sel" actionPerformedCommand="actionPerformedCommand" />
<Var name="actionPerformedLog" type="sstring" />
<Command name="actionPerformedCommand">
<local name="name" value="[?@%1%.group@!=,@%1%.group@,%1%]" />
<local name="type" value="@%1%.nodeType@" />
<local name="time" value="[*'{0:yy/MM/dd hh.mm.ss}',d:now]" />
<if condition="%2%==check^%3%==started">
<setfield field="actionPerformedLog.value" value="@%time%@ @def:Message.name@: checked @%name%@" />
<else condition="%2%==open^%3%==stopped">
<setfield field="actionPerformedLog.value" value="@%time%@ @def:Message.name@: opened @%name%@ to [*'{0:P1}',n:@%1%.op@]" /> </else> <else condition="%2%==close^%3%==stopped^@%type%@==ItemValve">
<setfield field="actionPerformedLog.value" value="@%time%@ @def:Message.name@: closed @%name%@ to [*'{0:P1}',n:@%1%.op@]" />
</else>
<!-- ... -->
<else>
<setfield field="actionPerformedLog.value" value="@%time%@ @def:Message.name@: action %2% on @%name%@" />
</else>
</if>
</Command>
ActionPerformedCommand
The actionPerformedCommand is called when an action is started or stopped over an item.
The arguments of the command are:
-
%0% sel itself
-
%1% action source node
-
%2% action name
-
%3% action state (started or stopped)
Activate or deactivate the Action Logger
Comment or uncomment the <patch name="sel" actionPerformedCommand="actionPerformedCommand" /> line.
The Action Logger is usually involved only in projects that include the XR Instructor, so it should be disabled in all the other cases.
Create or modify a new log
-
Add or modify an If condition.
-
Define the log condition based on the action name, state, and source item type.
For example, %2%==close^%3%==stopped^@%type%@==ItemValve means that the log is registered when a close action ends on a valve.
-
Update the actionPerformedLog.value with the desired text to be logged.