#C1926. Event Log Summarization
Event Log Summarization
Event Log Summarization
You are given a series of log entries from a system. Each log entry is a line containing a timestamp and an event type separated by a space. The timestamp is in the format \(\texttt{YYYY-MM-DD HH:MM:SS}\) and the event type is one of error
, warning
, or info
.
Your task is to produce a summary for each event type that appears in the logs. For each event type present, output three lines:
- The first line shows the event type (in uppercase with an added 'S', e.g. ERRORS, WARNINGS, INFOS) and the total count.
- The second line shows the earliest timestamp for that event.
- The third line shows the latest timestamp for that event.
The summary should list the events in the order: error, warning, info. If no log entries are provided (or only blank lines), output nothing.
All comparisons of timestamps can be performed lexicographically since the timestamp format \(\texttt{YYYY-MM-DD HH:MM:SS}\) is inherently ordered.
inputFormat
The input is provided via standard input (stdin) and consists of several lines. Each non-empty line represents a log entry in the format:
YYYY-MM-DD HH:MM:SS event_type
An empty line (or end of file) indicates the end of the input.
outputFormat
For each event type present in the input, output three lines (without any extra spaces):
- The first line:
EVENTS count: X
(whereEVENTS
is the uppercase form of the event type with an appended 'S', and X is the number of occurrences) - The second line:
EARLIEST: timestamp
, showing the smallest timestamp. - The third line:
LATEST: timestamp
, showing the largest timestamp.
The events should be reported in the following fixed order: error, warning, info. If an event type does not appear in the input, it should not be printed.
## sample2023-05-01 08:22:33 error
2023-05-01 09:15:12 info
2023-05-01 10:45:01 error
2023-05-01 12:30:45 warning
2023-05-01 15:00:00 info
2023-05-01 16:20:00 warning
ERRORS count: 2
EARLIEST: 2023-05-01 08:22:33
LATEST: 2023-05-01 10:45:01
WARNINGS count: 2
EARLIEST: 2023-05-01 12:30:45
LATEST: 2023-05-01 16:20:00
INFOS count: 2
EARLIEST: 2023-05-01 09:15:12
LATEST: 2023-05-01 15:00:00
</p>