Refactor Logging