Project

General

Profile

« Previous | Next » 

Revision 9545

lib/sh/util.sh: log+: set PS4 from $log_level instead of relative to its previous value. this allows PS4 to work properly at negative log_levels, in spite of the inability to store a "negative" value in a prefix string.

View differences:

lib/sh/util.sh
254 254
log+()
255 255
{
256 256
	# no local vars because w/o cmd, assignments should be applied to caller
257
	PS4="$(
258
	if test "$1" -gt 0; then echo "$(str="${PS4:0:1}" n="$1" repeat)$PS4"
259
	else echo "${PS4:$((-$1))}"
260
	fi)" \
257
	PS4="$(str="${PS4:0:1}" n=$((log_level+$1-1)) repeat)${PS4: -2}"; \
261 258
	log_level=$((log_level+$1)) \
262 259
	verbosity="$(float+int "$verbosity" "-$1")" "${@:2}"
263 260
}

Also available in: Unified diff