9/20
Sign inSign up free

1448. Replace print() With Real Logging

easy 10 XP ~10 minHands-on lab

/home/student/jobs/job.py mixes diagnostics and results in print() calls, so nobody can pipe its result anywhere, and the debug noise can't be switched off. Rework it with the logging module.

Task

  • The only thing on stdout is the result line, processed 5 items.
  • Diagnostics go to stderr through logging, formatted as LEVEL message (for example INFO starting job).
  • The level comes from the environment variable LOG_LEVEL (DEBUG, INFO, WARNING, ERROR) and defaults to INFO. Keep the existing messages at the levels their labels show.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.