feat: Enhance log functions with ANSI color formatting

- Added ANSI escape codes for improved log styling: light blue for info, orange for warnings, and red for errors.
- Updated all log functions (`info`, `warn`, `fatal`) to include bold and colored output.

Signed-off-by: Alessandro Pirastru <alessandro.pirastru.94@gmail.com>
This commit is contained in:
Alessandro Pirastru 2025-04-24 18:42:46 +02:00
parent f00029ddba
commit 979f666fc1

View file

@ -31,19 +31,26 @@ set -o noglob
#set -x
# --- helper functions for logs ---
# ANSI escape codes
LIGHT_BLUE='\033[38;5;117m'
ORANGE='\033[38;5;214m'
RED='\033[38;5;196m'
BOLD='\033[1m'
RESET='\033[0m'
info()
{
echo ' ' "$@"
echo -e "${BOLD}${LIGHT_BLUE}" '[INFO] ' "$@" "${RESET}"
}
warn()
{
echo '[WARN] ' "$@" >&2
echo -e "${BOLD}${ORANGE}" '[WARN] ' "$@" "${RESET}" >&2
}
fatal()
{
echo '[ERROR] ' "$@" >&2
echo -e "${BOLD}${RED}" '[ERROR] ' "$@" "${RESET}" >&2
exit 1
}