def count_types(gen):
    counts = {
        'TOTAL': 0,
        'DEBUG': 0,
        'INFO': 0,
        'WARNING': 0,
        'ERROR': 0,
        'TRACE': 0,
        'AUDIT': 0}

    laststatus = None
    for line in gen:
        counts['TOTAL'] = counts['TOTAL'] + 1
        for key in counts:
            if ' %s ' % key in line:
                laststatus = key
                continue
        if laststatus:
            counts[laststatus] = counts[laststatus] + 1
    return counts


# count up all the lines at all levels
dataset/ETHPy150Open openstack-infra/os-loganalyze/os_loganalyze/tests/test_wsgi.py/count_types/original