51 lines
541 B
Bash
51 lines
541 B
Bash
if [ -z "$_level" ]; then
|
|
_level=3
|
|
fi
|
|
|
|
dbg_all=1
|
|
dbg_trace=2
|
|
dbg_debug=3
|
|
dbg_info=4
|
|
dbg_warn=5
|
|
dbg_error=6
|
|
|
|
dbg() {
|
|
if [ "$1" -lt "$_level" ]; then
|
|
return 0
|
|
fi
|
|
|
|
case "$1" in
|
|
1)
|
|
lvl='trace'
|
|
clr='\e[0;90m'
|
|
;;
|
|
2)
|
|
lvl='trace'
|
|
clr='\e[0;90m'
|
|
;;
|
|
3)
|
|
lvl='debug'
|
|
clr='\e[0;94m'
|
|
;;
|
|
4)
|
|
lvl='info'
|
|
clr='\e[0;92m'
|
|
;;
|
|
|
|
5)
|
|
lvl='warn'
|
|
clr='\e[0;93m'
|
|
;;
|
|
6)
|
|
lvl='error'
|
|
clr='\e[0;91m'
|
|
;;
|
|
|
|
esac
|
|
|
|
if [ -z $_debug ]; then
|
|
return 0
|
|
fi
|
|
>&2 echo -e "$clr$(printf %-9s [$lvl])$2\e[0m"
|
|
}
|