Use a logger and format logging in one go

Also don't log conditionally, log everything.