Created
February 28, 2017 16:40
-
-
Save bunchc/7d554dd9df6c323cc26f6f34c2f56029 to your computer and use it in GitHub Desktop.
Bash Color Logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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