Skip to main content

← DevOps

Count errors in a log

easy

The first line has n. Each of the next n lines is a log line: "LEVEL service message...". Print each service that has at least one ERROR line with its number of errors, sorted by service name; print "none" if there are no errors.

Example 1: input

5
INFO api started
ERROR api timeout talking to db
WARN worker slow job
ERROR worker crashed
ERROR api 500 on /pay

Output

api 2
worker 1

Example 2: input

2
INFO a ok
DEBUG b fine

Output

none

Plus 1 hidden test when you check your answer.

Your solution

Read from standard input and print the answer. Run it on the examples as often as you like, then check it against every test.

Stuck?

Open hints one at a time. The write-up explains a full solution.

Discussion

Ask a question or share a tip. Please don’t post full solutions. Posts appear once a moderator approves them.

No posts yet.