Audit Log – Subroutine

Code Banner

For use with audit logging

 

/*************************************************************************************************
AUDIT LOGGING

Creates a subroutine to be called during key touch points during the script

*/
LET vCycleStart = TimeStamp(Now());
LET vAuditLog_Application = ‘Sales Dashboard’; // – Unique to each QVW
LET vAuditLog_ApplicationGroup = ‘Sales’;    // – Describes the applications group / project this QVW belongs to. This must be constant

 

SUB AuditLog (vCycleStart,vAuditLog_Application,vAuditLog_AttributeType,vAuditLog_AttributeName,vAuditLog_AttributeValue,vAuditLog_Start)

AuditLog:
LOAD

//What is that start time of this whole cycle? Groups various QVD builders together for reporting.
‘$(vCycleStart)’        AS     AuditLog_CycleStartTime

//ID for row written during this script execution. Used for sorting in analysis dashboard
,RowNo()          AS     AuditLog_CycleRowID

//What appGROUP is this (e.g. FR)?
,’$(vAuditLog_ApplicationGroup)’    AS     AuditLog_ApplicationGroup

//What app is this (e.g. PnL Builder)?
,’$(vAuditLog_Application)’      AS     AuditLog_Application

//What type of audit record is this? E.g. “Duration” “Variable” or “DB FACT Row Count”
,’$(vAuditLog_AttributeType)’     AS     AuditLog_AttributeType

//What type of attribute are we about to log an audit record for? E.g. Table Name, Tab Name or Variable Name
,’$(vAuditLog_AttributeName)’     AS     AuditLog_AttributeName

//What is the specific value for the AttributeName above? E.g. If its a variable it will be the value of the variable
,’$(vAuditLog_AttributeValue)’             AS     AuditLog_AttributeValue

//This will have been set at the start of the script section
,’$(vAuditLog_Start)’       AS     AuditLog_Start

//Get a timestamp for right now
,TimeStamp(Now())        AS     AuditLog_End

//End-Start = Duration. Saves doing it in a UI later. Converted to seconds.
,Num(Now()-‘$(vAuditLog_Start)’)*24*60*60  AS     AuditLog_Duration

AutoGenerate 1;

 

ENDSUB;

2 responses to “Audit Log – Subroutine

  1. Pingback: Audit Logging | qlikcentral·

  2. Hi my friend! I want to say that this post is awesome, nice written and include approximately all vital infos.
    I’d like to look more posts like this .

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s