midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/ex_rtl_log.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
#
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
#
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_rtl_log_env_vars() {
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	local _nvar=1 _arg _arg_len_max=0;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ex_rtl_log_msg info "Variables for this ${1:-build}:"; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	while [ ${_nvar} -le ${#} ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		_arg="$(eval echo \${${_nvar}})";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		_arg="${_arg%%=*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		if [ ${#_arg} -gt ${_arg_len_max} ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			_arg_len_max=${#_arg};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		fi; : $((_nvar+=1));
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_log_msg info "$(printf			\
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			"%${_arg_len_max}.${_arg_len_max}s=%s"	\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			"${1%%=*}" "$(ex_rtl_get_var_unsafe ${1#*=})")";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_rtl_log_set_vnfo_lvl() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	EXP_RTL_LOG_VNFO_LVL="${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_rtl_log_msg() {
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	local _lvl="${1}"; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 648b81
	if [ "${_lvl}" = vnfo ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	&& [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		return;
Lucio Andrés Illanes Albornoz (arab, vxp) 648b81
	elif [ "${_lvl}" = vvfo ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	&& [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 2 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 648b81
		return;
Lucio Andrés Illanes Albornoz (arab, vxp) 648b81
	elif [ "${_lvl}" = vvvo ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	&& [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 3 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 648b81
		return;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	case "${_lvl}" in
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		failexit) printf "\033[0m\033[${DEFAULT_LOG_MSG_FAIL_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		fail) printf "\033[0m\033[${DEFAULT_LOG_MSG_FAIL_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		info) printf "\033[0m\033[${DEFAULT_LOG_MSG_INFO_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		inf2) printf "\033[0m\033[${DEFAULT_LOG_MSG_INF2_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		vnfo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VNFO_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		vvfo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VVFO_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		vvvo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VVVO_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		succ) printf "\033[0m\033[${DEFAULT_LOG_MSG_SUCC_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		suc2) printf "\033[0m\033[${DEFAULT_LOG_MSG_SUC2_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	esac;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if [ ${#} -gt 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		printf "==> %s %s %s\033[0m\n" "$(ex_rtl_date)" "${1}" "$*";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	else
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		printf "==> %s %s\033[0m\n" "$(ex_rtl_date)" "${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	fi; [ ${_lvl} = failexit ] && exit 1 || return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
# vim:filetype=sh