Refactoring code for message logging protocols.