def set_log_range(module, releases, earlier, later, releases_list):
    """
    Set range to get logs for from parsed args or defaults if not given.

    Args:
        module(str): Module to get logs for
        releases(list of str): Releases range
        earlier(str): Specified start point
        later(str): Specified end point
        releases_list(list of str): List of releases from repository

    Raises:
        :class:`exception.ValueError`: Module <module> does not have a release
        <start>/<end>

    Returns:
        str, str: Start and end point to list releases for
    """

    if releases and len(releases) == 2:
        start = releases[0]
        end = releases[1]
    elif earlier:
        start = earlier
        end = 'HEAD'
    elif later:
        start = ""
        end = later
    else:
        start = ""
        end = 'HEAD'

    # Check that releases exist
    if start not in releases_list and start != "":
        raise ValueError("Module " + module + " does not have a release " +
                         start)
    if end not in releases_list and end != 'HEAD':
        raise ValueError("Module " + module + " does not have a release " +
                         end)

    return start, end