Using ArEventLog in Automation Basic

I currently created a task implementing the logging example code. I put the variable declarations in the parent module declarations. For the module using the logging, I declared and implemented a function to perform the logging as below. I found that I had to pass in the EventLog as an object. Not sure if this is the best way.

FUNCTION LogSTMsg : UINT (Gets code from EventId (bits 15-0).)
VAR_INPUT
Msg : STRING;
EventLog : EventLog_typ; (Event handling.)
END_VAR
END_FUNCTION

FUNCTION LogSTMsg
strcpy(ADR(EventLog.Event.AdditionalData),ADR(Msg));
EventLog.Event.AdditionalDataSize := strlen(ADR(EventLog.Event.AdditionalData)) + 1;
EventLog.Event.AdditionalDataFormat := arEVENTLOG_ADDFORMAT_TEXT;
EventLog.Commands.WriteUserEvent := TRUE;
END_FUNCTION