Revision 9542
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
215 | 215 |
export verbosity # propagate to invoked commands |
216 | 216 |
export PS4 # follows verbosity, so also propagate this |
217 | 217 |
|
218 |
# set log_level |
|
219 |
: "${log_level=$(( ${#PS4}-1 ))}" # defaults to # non-space symbols in PS4 |
|
220 |
export log_level # propagate to invoked commands |
|
221 |
|
|
218 | 222 |
verbosity_int() { round_down "$verbosity"; } |
219 | 223 |
|
220 | 224 |
# verbosities (and `make` equivalents): |
... | ... | |
252 | 256 |
if test "$1" -gt 0; then echo "$(str="${PS4:0:1}" n="$1" repeat)$PS4" |
253 | 257 |
else echo "${PS4:$((-$1))}" |
254 | 258 |
fi)" \ |
259 |
log_level="$(float+int "$log_level" "$1")" \ |
|
255 | 260 |
verbosity="$(float+int "$verbosity" "-$1")" "${@:2}" |
256 | 261 |
} |
257 | 262 |
log++() { log+ 1 "$@"; } |
258 | 263 |
log--() { log+ -1 "$@"; } |
259 |
alias log_local='declare PS4="$PS4" verbosity="$verbosity"' |
|
264 |
alias log_local=\ |
|
265 |
'declare PS4="$PS4" log_level="$log_level" verbosity="$verbosity"' |
|
260 | 266 |
alias log+='log_local; "log+"' # don't expand next word because it's not a cmd |
261 | 267 |
alias log++='log_local; "log++" ' # last space alias-expands next word |
262 | 268 |
alias log--='log_local; "log--" ' # last space alias-expands next word |
Also available in: Unified diff
lib/sh/util.sh: log++: also track a numeric log_level var, which follows the PS4 prefix