import logging


def _checker(value_list, source, data, flag):
    """
    Checks if values in the list are in data (Syntax warnings or errors).

    :param list value_list: List of values to check
    :param str source: Name of source that's being checked
    :param dict data: Data being checked
    :param str flag: What to do if value not found ("warnings" | "errors")
    :return: Number of hits (warnings/errors)
    :rtype: int
    """
    num_hits = 0
    for value in value_list:
        if value not in data:
            if flag == "warnings":
                logging.warning("Missing %s in %s", value, source)
            elif flag == "errors":
                logging.error("Missing %s in %s", value, source)
            else:
                logging.error("Invalid flag for _checker: %s", flag)
            num_hits += 1
    if num_hits > 0:
        logging.info("Total number of %s in %s: %d", flag, source, num_hits)
    return num_hits