Refactor log writer with interface and trait