1
0
mirror of https://github.com/EV21/dynb.git synced 2025-12-26 16:39:32 +01:00

2 Commits

Author SHA1 Message Date
ca2a5a0d62 feat: 🎨 colorful info, debug and error messages 2021-10-31 19:48:37 +01:00
06de559607 refactor: remove unused argbash fragment 2021-10-31 18:27:01 +01:00

18
dynb.sh
View File

@@ -73,6 +73,14 @@ _debug=0
_minimum_looptime=60 _minimum_looptime=60
_loopMode=0 _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() { function loopMode() {
if [[ $_loopMode -eq 1 ]]; then if [[ $_loopMode -eq 1 ]]; then
return 0 return 0
@@ -90,16 +98,18 @@ function debugMode() {
} }
function infoMessage() { function infoMessage() {
echo "$(logtime) INFO: $*" echo -e "${green_color}$(logtime) INFO: $*${reset_color_modification}"
} }
function debugMessage() { function debugMessage() {
if debugMode; then if debugMode; then
echo "$(logtime) DEBUG: $*" echo -e "${yellow_color}$(logtime) DEBUG: ${*}${reset_color_modification}"
fi 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() { function logtime() {
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
@@ -726,5 +736,3 @@ function dynb() {
dynb "${@}" dynb "${@}"
exit $? exit $?
# ] <-- needed because of Argbash