import re


def parse_log_entry(msg):
    """
    Parse a log entry from the format
    $ip_addr - [$time_local] "$request" $status $bytes_sent $http_user_agent"
    to a dictionary
    """
    data = {}

    # Regular expression that parses a log entry
    search_term = '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+\-\s+\[(.*)]\s+'\
        '"(\/[/.a-zA-Z0-9-]+)"\s+(\d{3})\s+(\d+)\s+"(.*)"'

    values = re.findall(search_term, msg)

    if values:
        val = values[0]
        data['ip'] = val[0]
        data['date'] = val[1]
        data['path'] = val[2]
        data['status'] = val[3]
        data['bytes_sent'] = val[4]
        data['agent'] = val[5]
    return data