Refactoring how logging works