def METHOD_NAME(out, opts=None, **kwargs):
    """
    Return a printer function
    """
    if opts is None:
        opts = {}
    if "output" in opts and opts["output"] != "highstate":
        # new --out option, but don't choke when using --out=highstate at CLI
        # See Issue #29796 for more information.
        out = opts["output"]
    # Handle setting the output when --static is passed.
    if not out and opts.get("static"):
        if opts.get("output"):
            out = opts["output"]
        elif opts.get("fun", "").split(".")[0] == "state":
            # --static doesn't have an output set at this point, but if we're
            # running a state function and "out" hasn't already been set, we
            # should set the out variable to "highstate". Otherwise state runs
            # are set to "nested" below. See Issue #44556 for more information.
            out = "highstate"
    if out == "text":
        out = "txt"
    elif out is None or out == "":
        out = "nested"
    if opts.get("progress", False):
        out = "progress"
    opts.update(kwargs)
    if "color" not in opts:
        def is_pipe():
            """
            Check if sys.stdout is a pipe or not
            """
            try:
                fileno = sys.stdout.fileno()
            except (AttributeError, io.UnsupportedOperation):
                fileno = -1  # sys.stdout is StringIO or fake
            return not os.isatty(fileno)
        if opts.get("force_color", False):
            opts["color"] = True
        elif (
            opts.get("no_color", False) or is_pipe() or salt.utils.platform.is_windows()
        ):
            opts["color"] = False
        else:
            opts["color"] = True
    else:
        if opts.get("force_color", False):
            opts["color"] = True
        elif opts.get("no_color", False) or salt.utils.platform.is_windows():
            opts["color"] = False
        else:
            pass
    outputters = salt.loader.outputters(opts)
    if out not in outputters:
        # Since the grains outputter was removed we don't need to fire this
        # error when old minions are asking for it
        if out != "grains":
            log.error(
                "Invalid outputter %s specified, fall back to nested",
                out,
            )
        return outputters["nested"]
    return outputters[out]