#C14012. Log Analysis Report
Log Analysis Report
Log Analysis Report
You are given a list of log entries. Each log entry is a string containing a timestamp and some event details. The timestamp is in the format \(\texttt{%Y-%m-%d %H:%M:%S}\), followed by a space and then the event message.
Your task is to generate a summary report for a given time interval. In the report, count the number of log entries (within the interval, inclusive) that contain one of the following keywords in their event details: ERROR
, WARNING
, or INFO
.
If a log entry is invalid (i.e. does not conform to the expected format), it should be skipped.
Note: The comparison of timestamps is done using the provided format and is inclusive of the boundaries.
inputFormat
Standard input (stdin) contains the following:
- An integer \(N\) representing the number of log entries.
- Next \(N\) lines, each line is a log entry. Each entry is expected to have a timestamp in the format
%Y-%m-%d %H:%M:%S
followed by a space and event details. - A line containing the start time of the interval (in the same format).
- A line containing the end time of the interval (in the same format).
Example:
5 2023-05-15 10:15:53 ERROR Disk space low 2023-05-15 10:15:54 INFO User logged in 2023-05-15 10:16:10 WARNING High memory usage 2023-05-15 10:17:15 ERROR Failed to connect to server 2023-05-15 10:18:20 INFO User logged out 2023-05-15 10:15:54 2023-05-15 10:18:20
outputFormat
Standard output (stdout) should contain three lines:
- First line: count of log entries whose event details contain the keyword
ERROR
. - Second line: count of log entries whose event details contain the keyword
WARNING
. - Third line: count of log entries whose event details contain the keyword
INFO
.
Only the log entries with valid formats and timestamps within the given interval (inclusive) are considered.
## sample5
2023-05-15 10:15:53 ERROR Disk space low
2023-05-15 10:15:54 INFO User logged in
2023-05-15 10:16:10 WARNING High memory usage
2023-05-15 10:17:15 ERROR Failed to connect to server
2023-05-15 10:18:20 INFO User logged out
2023-05-15 10:15:54
2023-05-15 10:18:20
1
1
2
</p>