Consolidated logging into one function.