Spec a Bash logging helper scripts can source

Vibe codingMedium25 min

Your task

Your team has 15 Bash scripts for ops tasks, and each prints messages its own way. You want one shared file, lib/log.sh, that every script sources. It gives log_info, log_warn and log_error, adds a timestamp and respects a LOG_LEVEL setting. An agent will write it.

Write the spec you would hand the agent.

What you know:

  • every script starts with set -euo pipefail
  • some scripts print data to stdout for other tools to read, like ./list-hosts.sh | xargs ...
  • scripts run on Linux servers and on developers' Macs, and macOS ships Bash 3.2
  • operators sometimes want a copy of the logs in a file

Then, in a few sentences: what does "add some logging functions to my script" get wrong?