import base64


def api_log_item(file_path, file_name, log_path_url):
    """Create a log item from the file

    Returns: {
        file_name: the filename of the entry
        url: for retrieving the file
        head: first 1500 bytes of the log file, base64 encoded
    }
    """
    with open(file_path, "rb") as f:
        head = f.read(1500)

    return {
        'file_name': file_name,
        'url': log_path_url + file_name,
        'head': base64.b64encode(head)
    }