Print incoming and outgoing messages for logging.