<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setup(level=logging.WARNING, outputs=[output.STDERR], program_name=None, capture_warnings=True):
 """Setup Python logging. This will setup basic handlers for Python logging. :param level: Root log level. :param outputs: Iterable of outputs to log to. :param program_name: The name of the program. Auto-detected if not set. :param capture_warnings: Capture warnings from the `warnings' module. """

    root_logger = logging.getLogger(None)

    # Remove all handlers
    for handler in list(root_logger.handlers):
        root_logger.removeHandler(handler)

    # Add configured handlers
    for out in outputs:
        if isinstance(out, str):
            out = output.preconfigured.get(out)
            if out is None:
                raise RuntimeError("Output {} is not available".format(out))
        out.add_to_logger(root_logger)

    root_logger.setLevel(level)

    program_logger = logging.getLogger(program_name)

    def logging_excepthook(exc_type, value, tb):
        program_logger.critical(
            "".join(traceback.format_exception(exc_type, value, tb)))

    sys.excepthook = logging_excepthook

    if capture_warnings:
        logging.captureWarnings(True)