Refactor logging. [minor]