From 6eae43002f3934ca53130ee438c29a7ca3fce70e Mon Sep 17 00:00:00 2001 From: Eduard Veit Date: Sun, 31 Oct 2021 19:48:37 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=A8=20colorful=20info,=20debug?= =?UTF-8?q?=20and=20error=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dynb.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dynb.sh b/dynb.sh index 831aa49..ef6c7a4 100755 --- a/dynb.sh +++ b/dynb.sh @@ -73,6 +73,14 @@ _debug=0 _minimum_looptime=60 _loopMode=0 +# Ansi color code variables +yellow_color="\e[0;33m" +green_color="\e[0;92m" +expand_bg="\e[K" +red_color_bg="\e[0;101m${expand_bg}" +bold="\e[1m" +reset_color_modification="\e[0m" + function loopMode() { if [[ $_loopMode -eq 1 ]]; then return 0 @@ -90,16 +98,18 @@ function debugMode() { } function infoMessage() { - echo "$(logtime) INFO: $*" + echo -e "${green_color}$(logtime) INFO: $*${reset_color_modification}" } function debugMessage() { if debugMode; then - echo "$(logtime) DEBUG: $*" + echo -e "${yellow_color}$(logtime) DEBUG: ${*}${reset_color_modification}" fi } -function errorMessage() { printf "$(logtime) ERROR: %s\n" "$*" >&2; } +function errorMessage() { + echo -e "${red_color_bg}${bold}$(logtime) ERROR: $*${reset_color_modification}" >&2 +} function logtime() { LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")