gitrefresh

Easily export, reinitialize and update all git repositories in a file hierarchy
git clone git://git.defalsify.org/gitrefresh.git
Info | Log | Files | Refs | README | LICENSE

bdbg.sh (823B)


      1 # This script normally lives in https://git.defalsify.org/bashbdbg
      2 # Licenced under Do What The Fuck You Want Licence v2
      3 # (c) 2021-2022 by lash 
      4 
      5 bdbg_check_env_level() {
      6 	if [ -z "$BDBG_LEVEL" ]; then
      7 		_level=3
      8 	else
      9 		_level=$BDBG_LEVEL
     10 	fi
     11 }
     12 
     13 bdbg_check_env_toggle() {
     14 	if [ ! -z "$BDBG" ]; then
     15 		if [ "$BDBG" -gt "0" ]; then
     16 			_debug=1
     17 		fi
     18 	fi
     19 }
     20 
     21 
     22 dbg() {
     23 	if [ "$1" -lt "$_level" ]; then
     24 		return 0
     25 	fi
     26 
     27 	case "$1" in
     28 		1)
     29 			lvl='debug'
     30 			clr='\e[0;96m'
     31 			;;
     32 		2)
     33 			lvl='info'
     34 			clr='\e[0;92m'
     35 			;;
     36 
     37 		3)
     38 			lvl='warn'
     39 			clr='\e[0;93m'
     40 			;;
     41 		4)
     42 			lvl='error'
     43 			clr='\e[0;91m'
     44 			;;
     45 
     46 	esac
     47 
     48 	if [ -z $_debug ]; then
     49 		return 0
     50 	fi
     51 	>&2 echo -e "$clr$(printf %-9s [$lvl])$2\e[0m"
     52 }
     53 
     54 bdbg() {
     55 	if [ -z "$_level" ]; then
     56 		bdbg_check_env_level
     57 	fi
     58 
     59 	if [ -z "$_debug" ]; then
     60 		bdbg_check_env_toggle
     61 	fi
     62 }