from typing import Sequence
import re


def parse_log(log_file: str, fields: Sequence[str]):
    """parse fields from the log file

    Args:
        log_file (str): the log file path.
        fields (Sequence[str]): The wanted fields.

    Returns: dict. key is the field name and value is the parsed values.

    """
    with open(log_file, "r") as f:
        lines = f.readlines()

    res = {}
    for field in fields:
        res[field] = []

    for line in lines:
        matches = re.findall(r"(\w+): ([0-9.]*[0-9])", line)
        for (k, v) in matches:
            if k in fields:
                res[k].append(float(v))

    return res