Updated the logging function