Added colours to output level

This commit is contained in:
Jeroen De Meerleer 2018-11-30 16:56:15 +01:00
parent 13a420a5b1
commit b872adb7fe
1 changed files with 11 additions and 11 deletions

View File

@ -14,8 +14,8 @@ GetOptions() {
! getopt --test > /dev/null ! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
VerboseOutput 5 "\`getopt --test\` failed" VerboseOutput 5 "\`getopt --test\` failed"
echo "Sorry, It seems that your shell is not supported" VerboseOutput 5 "Sorry, It seems that your shell is not supported"
echo "If you're using mac or another unix-like system, please install GNU getopt" VerboseOutput 5 "If you're using MacOS or another unix-like system, please install GNU getopt"
exit 1 exit 1
fi fi
@ -69,7 +69,7 @@ GetOptions() {
break break
;; ;;
*) *)
echo "Programming error" VerboseOutput 5 "Programming error"
return 3 return 3
;; ;;
esac esac
@ -109,26 +109,26 @@ VerboseOutput() {
if [[ $verbose -le $1 ]]; then if [[ $verbose -le $1 ]]; then
case "$1" in case "$1" in
0) 0)
level="Verbose" level="\033[1;36mVerbose\033[0m"
;; ;;
1) 1)
level=" Debug " level="\033[1;34m Debug \033[0m"
;; ;;
2) 2)
level=" Info " level="\033[1;37m Info \033[0m"
;; ;;
3) 3)
level="Warning" level="\033[1;33mWarning\033[0m"
;; ;;
4) 4)
level=" Error " level="\033[1;31m Error \033[0m"
;; ;;
5) 5)
level=" Fatal " level="\033[1;30m Fatal \033[0m"
;; ;;
esac esac
echo "[$level] $2" >&2 echo -e "[$level] $2" >&2
fi fi
} }
@ -199,7 +199,7 @@ if [[ -f /tmp/music-sync-filelist ]]; then
fi fi
CreateFileList $source $dest "" CreateFileList $source $dest ""
if [[ ! -f /tmp/music-sync-filelist ]]; then if [[ ! -f /tmp/music-sync-filelist ]]; then
VerboseOutput "Info" "Nothing to do!" VerboseOutput 2 "Nothing to do!"
exit 0 exit 0
fi fi
ConvertFiles ConvertFiles