A Reusable Logging Library

medium 20 XP ~10 minHands-on lab Pro

Every team script prints messages its own way. Write one library they can all source.

Task

Create /home/student/lib/log.sh defining three functions:

  • log_info MESSAGE…, log_warn MESSAGE…, log_error MESSAGE…
  • each prints one line: TIMESTAMP [LEVEL] MESSAGE, where TIMESTAMP is the current UTC time like 2026-10-20T14:03:09Z and LEVEL is INFO, WARN or ERROR
  • log_info and log_warn print to stdout; log_error prints to stderr
  • all arguments form the message, separated by single spaces
  • the environment variable LOG_LEVEL filters output: info (default) shows everything, warn hides INFO, error shows only ERROR

Sourcing the file must print nothing, must not exit the caller, and must not change the caller's shell options (for example, no set -e).

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.

TerminalNot started

Your machine is ready to start

Create a free account to open a machine and get graded.