benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2fede660-693f-5888-a6bf-71f8b0c3dd09

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import os
import re

def task_func(log_file_path: str, keywords: list):
    '''
    Check a log file and format the lines that contain certain keywords. This code reads the log file specified by log_file_path; searches for lines containing any of the keywords provided in the list;
    and formats each line to display the keyword, the timestamp, and the message separated by 20 spaces.
    
    Parameters:
    - log_file_path (str): The path to the log file to be checked.
    - keywords (list): A list of keywords to be searched for in the log file.
    
    Returns:
    - formatted_lines (list): Returns a list of formatted strings containing the relevant information.
    
    Requirements:
    - os
    - re
    
    Example:
    >>> task_func('/path/to/log_file.log', ['ERROR', 'WARNING'])
    ['    ERROR :    11:30:10 : This is an error message', '    WARNING :    11:35:10 : This is a warning message']
    '''

instruct prompt

Check a log file and format the lines that contain certain keywords. This code reads the log file specified by log_file_path; searches for lines containing any of the keywords provided in the list; and formats each line to display the keyword, the timestamp, and the message separated by 20 spaces.
The function should output with:
    formatted_lines (list): Returns a list of formatted strings containing the relevant information.
You should write self-contained code starting with:

Code

import os
import re
def task_func(log_file_path: str, keywords: list):

code prompt

Code

import os
import re
def task_func(log_file_path: str, keywords: list):

entry point

task_func

libs

  • re
  • os

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import