Skip to content

Instantly share code, notes, and snippets.

@bunchc
Created February 28, 2017 16:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bunchc/7d554dd9df6c323cc26f6f34c2f56029 to your computer and use it in GitHub Desktop.
Save bunchc/7d554dd9df6c323cc26f6f34c2f56029 to your computer and use it in GitHub Desktop.
Bash Color Logging
# EasyColors
if [ ${libout_color:-1} -eq 1 ]; then
DEF_COLOR="\x1b[0m"
BLUE="\x1b[34;01m"
CYAN="\x1b[36;01m"
GREEN="\x1b[32;01m"
RED="\x1b[31;01m"
GRAY="\x1b[37;01m"
YELLOW="\x1b[33;01m"
fi
debug() {
if [ ${verbose_level:-0} -gt 3 ]; then
echo "$CYAN >>$DEF_COLOR $@"
fi
}
info() {
if [ ${verbose_level:-0} -gt 2 ]; then
echo "$GREEN >>$DEF_COLOR $@"
fi
}
warn() {
if [ ${verbose_level:-0} -gt 1 ]; then
echo "$YELLOW >>$DEF_COLOR $@"
fi
}
message() {
if [ ${verbose_level:-0} -gt 0 ]; then
echo "$GREEN >>$DEF_COLOR $@"
fi
}
error() {
echo "$RED >>$DEF_COLOR $@"
}
die() {
error "$@"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment