Project

General

Profile

« Previous | Next » 

Revision 12805

lib/sh/util.sh: log(): highlight log_level 1 messages to stand out against other output, for easier debugging

View differences:

trunk/lib/sh/util.sh
483 483
can_log() { test "$(verbosity_int)" -gt 0; }
484 484
	# verbosity=0 turns off all logging
485 485

  
486
log() { if can_log; then echo "$log_indent$PS4$1" >&"$log_fd"; fi; }
486
can_highlight_msg() { test "$log_level" -le 1; }
487 487

  
488
highlight_msg()
489
{
490
	local highlight="$(can_highlight_msg; exit2bool)"
491
	echo "${highlight:+}$1${highlight:+}"
492
}
493

  
494
log() # highlights log_level 1 messages to stand out against other output
495
{ if can_log; then echo "$log_indent$PS4$(highlight_msg "$1")" >&"$log_fd"; fi;}
496

  
488 497
log_custom() # usage: symbol=... log_custom msg
489 498
{ log_indent="${log_indent//[^ ]/$symbol}" PS4="${PS4//[^ ]/$symbol}" log "$@";}
490 499

  

Also available in: Unified diff