Project

General

Profile

« Previous | Next » 

Revision 9299

lib/sh/util.sh: log++/-- (and helpers PS4++/--): added functions for these so they can also be used in other contexts that don't support aliases. note that direct callers of the functions would still need to localize the PS4/$verbosity values using log_local.

View differences:

lib/sh/util.sh
178 178
# for unfiltered messages, the log_level is 0 (i.e. still output at verbosity=0)
179 179
# to view a message's log_level, count the # of + signs before it in the output
180 180

  
181
# usage: in func:      PS4++; ...
181
# usage: in func:      PS4++; ...         OR  PS4_local; "PS4++"; ...
182 182
#        outside func: PS4++; ...; PS4--
183
alias PS4++='declare PS4="${PS4:0:1}$PS4"'
184
alias PS4--='declare PS4="${PS4#${PS4:0:1}}"'
183
PS4++() { PS4="${PS4:0:1}$PS4"; }
184
PS4--() { PS4="${PS4#${PS4:0:1}}"; }
185
alias PS4_local='declare PS4="$PS4"'
186
alias PS4++='PS4_local; "PS4++"'
187
alias PS4--='PS4_local; "PS4--"'
185 188

  
186
# usage: in func:      log++; ...
189
# usage: in func:      log++; ...         OR  log_local; "log++"; ...
187 190
#        outside func: log++; ...; log--
188
alias log++='{ PS4++; declare verbosity="$verbosity"; let! verbosity--; }'
189
alias log--='{ PS4--; declare verbosity="$verbosity"; let! verbosity++; }'
191
log++() { "PS4++"; let! verbosity--; }
192
log--() { "PS4--"; let! verbosity++; }
193
alias log_local='PS4_local; declare verbosity="$verbosity"'
194
alias log++='log_local; "log++"'
195
alias log--='log_local; "log--"'
190 196

  
191 197

  
192 198
# indent for call tree. this is *not* the log_level (below).

Also available in: Unified diff