Last log line by keyword
Your task
You are grepping a cron job's output by hand and want the most recent mention of a task. Each line has the form "<timestamp> <LEVEL> <message>". Given the lines in the order they were written and a keyword, return the ENTIRE last line whose message part (the text after the level token) contains the keyword as a substring, timestamp and level included in what you return. If nothing matches, return the empty string.
Examples
last_match_line(lines: list[str], keyword: str) -> strExample 1
Input
last_match_line(["2026-07-01T02:00:00 INFO backup started", "2026-07-01T02:05:00 ERROR backup failed disk full", "2026-07-01T03:00:00 INFO cleanup started"], "backup")Output
"2026-07-01T02:05:00 ERROR backup failed disk full"