code indentation tidy and added error function in logger to log errors.