Added event logging function