Ignition doesn’t handle the auditing in the same way that Wonderware does. Ignition uses the audit log to record things that users do and some alarm notification information, there’s no built in way to log tag change events into the audit log.
Options for logging tag change events is to use the Historian and query the Historian for change events, use alarming on the tag with a Priority setting of Diagnostic, or roll your own.
I think in your case you are looking to mimic the way Wonderware stores tag changed events, in the same log as user events, in which case you would roll your own and you are on the right track. The way I would do this is to create a Gateway script and call that script from any tag value changed function that I want to log to the audit log.
Here’s the call used in the tag Valve Changed function - shared.EventLog.LogEvent(tagPath, previousValue, currentValue, initialChange, missedEvents)
Create a Gateway script (under Global/Script Library) called EventLog and you can add the following function to the script, you’ll need to modify the script for your table and column names - [code]def LogEvent(tagPath, previousValue, currentValue, initialChange, missedEvents):
User = 'Ignition'
UserHost = 'Gateway'
Action = 'tag event'
ActionTarget = str(tagPath)
ActionValue = str(currentValue.value)
StatusCode = 0
OriginatingSystem = 'Gateway'
OriginatingContext = 10 #value to enable searching for tag events
system.db.runPrepUpdate("INSERT INTO audit_log " \
"(event_timestamp, user, user_host, action, action_target, " \
"action_value, status_code, originating_system, originating_context) " \
"VALUES " \
"(now(), ?, ?, ?, ?, " \
"?, ?, ?, ?)",
[User, UserHost, Action, ActionTarget,
ActionValue, StatusCode, OriginatingSystem, OriginatingContext],
database='SCADA') #must include database connection name[/code]
- The Tag Value Changed function is executed by the Gateway, so there is no Client information (user, project) available.
- Although the doc information in the Value Changed function says the tagPath is a string, I think it’s an object which is why it’s wrapped with str().
- The action_value column in the table is a string column, which is why the currentValue.value is wrapped with str().