Added a logging method to shorten repeated code.