Pulled code out into smaller methods

Pulled some code out into smaller methods, so we should have it easier later one to support multiple logging formats.