You are given application log lines. Each line is expected to follow this format:
[LEVEL] timestamp, eventName, errorCode, text
LEVEL
is a single character such as
I
,
W
,
E
inside square brackets (e.g.,
[I]
).
text
may contain arbitrary characters (assume it does
not
contain a newline).
Write a Python function that parses a list of log lines and returns the count of each errorCode.
lines
, where each string is one log line.
errorCode
(string) to its occurrence count (integer).
errorCode
as a string (e.g.,
"404"
,
"E123"
).
Input:
[I] 2026-01-01T00:00:00Z, Login, E123, user not found
[W] 2026-01-01T00:00:01Z, Login, E123, retry
[E] 2026-01-01T00:00:02Z, Payment, P007, declined
Output:
{ "E123": 2, "P007": 1 }