Refactor log management to a separate class