Part 2 — logstats: debug a small CLI
logstats summarises log files by severity level. It is a two-module tool:
logstats/parser.py does the counting, logstats/cli.py is the command-line
front end.
Log lines look like this (see sample.log):
2024-03-01 09:00:00 INFO service started
2024-03-01 09:00:04 ERROR payment gateway timeout
Usage:
python -m logstats.cli sample.log # counts per level
python -m logstats.cli a.log b.log --top 2 # aggregate files, top 2 levels
Your task
The tool has bugs. The test suite describes the intended behaviour and currently fails. Debug the tool until the suite passes:
pip install -e ".[dev]"
python -m pytest
Fix the causes, not the symptoms — we read the diff, not just the test
output. Note anything interesting in the repository-level NOTES.md.