At NovaFlow, a data pipeline script emits log lines for each processing step. Implement a function that scans these lines and returns a summary of exception activity by counting failed records, collecting unique error types, and preserving the order of the first occurrence of each error.
Given a list of strings logs, where each string is one log line, return a dictionary with:
failed_count: total number of lines that contain an exceptionerror_types: a list of unique exception names in first-seen orderlatest_message: the message text from the last exception line, or "" if none existA line is considered an exception line if it matches this format exactly:
ERROR:<ExceptionName>:<message>
<ExceptionName> contains only letters and ends with Error or Exception. The <message> part may contain spaces and punctuation.
logs — list of stringsfailed_count, error_types, and latest_messageExample 1
Input: logs = ["INFO:start", "ERROR:ValueError:bad row", "ERROR:TypeError:wrong type"]
Output: {"failed_count": 2, "error_types": ["ValueError", "TypeError"], "latest_message": "wrong type"}
Explanation: Two exception lines appear, both unique, and the last message is from the final error line.
Example 2
Input: logs = ["INFO:ok", "WARN:retry", "INFO:done"]
Output: {"failed_count": 0, "error_types": [], "latest_message": ""}
Explanation: No line matches the exception format.
1 <= len(logs) <= 10^40 <= len(logs[i]) <= 200