Objective
Create a Python program that analyses an application log using regular expressions and counters, and shows a summary.
Instructions
- Read an integer
nand thennlines. A valid line has the formatYYYY-MM-DD HH:MM:SS LEVEL message, with levelDEBUG,INFO,WARNINGorERROR. The message may contain spaces. - Show four
LEVEL: nlines, in the order DEBUG, INFO, WARNING, ERROR, with the number of valid lines of each level. - Show
Invalid lines: kwith the lines that do not match the format. - Show
Day with most errors: YYYY-MM-DD (n)with the day that has the most ERROR lines (on a tie, the earlier day), orNo errorsif there are none. - Show
Busiest hour: HH (n)with the hour of the day (00-23) with the most valid lines (on a tie, the smaller hour), orNo recordsif there are no valid lines.
5
2026-03-01 10:15:32 INFO Servidor iniciado
2026-03-01 10:20:01 ERROR Disco lleno
2026-03-02 11:00:00 ERROR Sin memoria
linea rota
2026-03-02 11:30:10 WARNING Memoria alta
DEBUG: 0
INFO: 1
WARNING: 1
ERROR: 2
Invalid lines: 1
Day with most errors: 2026-03-01 (1)
Busiest hour: 10 (2)
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise