refactor the logging utils