def parser(fname):
    """
    transform logfile into header, log, and ignored lines
    """
    with open(fname, 'r') as fid:
        lines = fid.readlines()

    fid.close()
    in_header = True
    is_notice = False
    ignored_lines = []
    protocol = []
    header = {}

    for line in lines:
        if line[:13] == '-* NOTICE  *-':
            is_notice = True
        else:
            is_notice = False

        if in_header:
            # this means header is over
            if is_notice:
                in_header = False
            else:
                if len(line) > 3:
                    key, value = line.split(':', 1)
                    header[key] = value.strip()

        else:
            if is_notice:
                fields = line[15:].split(' - ', 4)
                time = fields[0]
                stamp = int(fields[1])
                msg = fields[2].strip().replace('\r', '')

                if len(fields) == 4:
                    msg2 = fields[3].strip().replace('\r', '')
                else:
                    msg2 = ''

                protocol.append((time, stamp, msg, msg2))

            elif line.startswith('Log file successfully moved to'):
                target = line.split()[-1]
                # this indicates a log file move
                # mov is our key
                protocol.append((0, 0, 'mov', target))

            else:
                ignored_lines.append(line.strip())

    try:
        bn = 'Cheetah ' + header['Cheetah Build Number']
    except KeyError:
        bn = 'ATLAS ' + header['Cheetah ATLAS Build Number']
    print(bn)
    return header, protocol, ignored_lines