Re-order some commands so we don't call log_begin_msg without calling log_end_msg.