Added a logging function