Logging and Observability
Log Level
Choose Detail
A logging helper can select how much detail to write while keeping the output format stable for readers and tools.
Program
Play the script to choose the log level and see the resulting log line.
log_level_line.sh
#!/usr/bin/env bash
level=
case "$level" in
info) message="service ready" ;;
debug) message="cache warmed" ;;
esac
line="$level:$message"
echo "$line"
#!/usr/bin/env bash
level=
case "$level" in
info) message="service ready" ;;
debug) message="cache warmed" ;;
esac
line="$level:$message"
echo "$line"
log level
The log level names how detailed the message is.
stable format
A stable log shape is easier to search and parse.
message
The message carries the human-readable event detail.