def fmt_cmd_out_for_log(result_or_error, combine_out_err):
    """ Formats result of (or error raised from) subprocess.run for logging.

    :param result_or_error: Result/error to format
    :type result_or_error: ``subprocess.CalledProcessError`` or ``subprocess.CompletedProcess``
    :param combine_out_err: Whether or not stdout and stderr of the subprocess are combined
        into a single stream (more human readable when they're interleaved),
        defaults to `False`
    :type combine_out_err: ``bool``
    :return: Formatted result/error
    :rtype: ``str``
    """
    if combine_out_err:
        return '\nRETCODE: {rc}\nOUTPUT:\n{o}'.format(rc=result_or_error.
            returncode, o=result_or_error.stdout)
    else:
        return '\nRETCODE: {rc}\nSTDOUT:\n{o}STDERR:\n{e}'.format(rc=
            result_or_error.returncode, o=result_or_error.stdout, e=
            result_or_error.stderr)
