Extract logger

Clean up a bit of duplication