Logging refactor