human
Complete this python program:
def logged_run_process(reactor, command):
assistant
#Here is the Python code you requested.

    """Run a child process, and log the output as we get it.
    :param reactor: An ``IReactorProcess`` to spawn the process on.
    :param command: An argument list specifying the child process to run.
    :return: A ``Deferred`` that calls back with ``_ProcessResult`` if the
    process exited successfully, or errbacks with
    ``_CalledProcessError`` otherwise.
    """
    d = Deferred()
    action = TWISTED_CHILD_PROCESS_ACTION(command=command)
    with action.context():
        d2 = DeferredContext(d)
        protocol = _LoggingProcessProtocol(d, action)
        reactor.spawnProcess(protocol, command[0], command)
        def process_ended((reason, output)):
            status = reason.value.status
            if status:
                raise _CalledProcessError(returncode=status, cmd=command, output=output)
            return _ProcessResult(command=command, status=status, output=output)
        d2.addCallback(process_ended)
        d2.addActionFinish()
        return d2.result