Added logging function