python · level 3 check

a shipped log analyser.

Time to ship a real tool. `logcheck` reads a server log and reports on it. The first line you type is its command line, like `--level warning --top 2`. Every line after that is a log line, until a line that says `END`.

Each log line has a time, a level and a message, like `09:15 ERROR disk full`. Lines that do not fit are skipped and counted, never crashed on. The levels are DEBUG, INFO, WARNING and ERROR, and `--level` hides anything less serious.

The report counts each level, ranks the most common messages and says how many lines were skipped. A bad option gets one polite sentence and exit code 2, not a traceback. Fill in each `____`, run it, then feed it a log of your own.

Fill in every ____ then run the checks.
  1. 1 It counts each leveluses: Counter
  2. 2 It hides less serious levels with --leveluses: argparse
  3. 3 It ranks the most common messages with --topuses: Counter
  4. 4 It skips bad lines without crashinguses: validating input
  5. 5 It rejects a bad option politelyuses: failing politely
  6. 6 It copes with an empty loguses: edge cases

Take as long as you like and try as many times as you want.