Project

General

Profile

« Previous | Next » 

Revision 12829

lib/sh/util.sh: clog*: renamed to log* for clarity (possible now that log* is no longer used for function-local log_level setting)

View differences:

trunk/lib/runscripts/util.run
93 93

  
94 94
# by default, use all subdirs, including .*
95 95
if ! isset subdirs; then subdirs=($(enter_top_dir; wildcard. {.,}*/)); fi
96
clog-- echo_vars subdirs
96
log-- echo_vars subdirs
97 97

  
98 98
fwd() # usage: [subdirs=(...);] fwd target args... # or use fwd_self
99 99
{
trunk/lib/sh/local.sh
82 82
	)|psql__db_sh "$@"
83 83
}
84 84

  
85
public_schema_exists() { echo_func; schema=public clog++ pg_schema_exists; }
85
public_schema_exists() { echo_func; schema=public log++ pg_schema_exists; }
86 86

  
87 87
pg_dump_local() { echo_func; use_local; pg_dump "$@"; }
88 88

  
trunk/lib/sh/make.sh
59 59
	(
60 60
		# at verbosity < 4, hide messages about making included Makefiles
61 61
		# this can reduce # lines of output to 1/3 as much
62
		if test ! "$make_filter_active" && ! clog+ 3 can_log; then
62
		if test ! "$make_filter_active" && ! log+ 3 can_log; then
63 63
			local_export make_filter_active=1
64
			local cmd="$(clog++ sys_cmd_path "$(self_name)")"; echo_vars cmd
65
			fd="$log_fd" clog++ filter_fd sed \
64
			local cmd="$(log++ sys_cmd_path "$(self_name)")"; echo_vars cmd
65
			fd="$log_fd" log++ filter_fd sed \
66 66
-e "\%^$cmd ([^-][^[:space:]]*)?Makefile%,/^make\[[[:digit:]]+\]: .*Makefile/d" \
67 67
-e                                       '/^make\[[[:digit:]]+\]: .*Makefile/d'
68 68
		fi
trunk/lib/sh/util.sh
164 164
# allows running a system command of the same name as the script
165 165
alias cmd2sys="$(cat <<'EOF'
166 166
declare _1="$1"; shift
167
_1="$(indent; clog++ sys_cmd_path "$_1")" || return
167
_1="$(indent; log++ sys_cmd_path "$_1")" || return
168 168
set -- "$_1" "$@"
169 169
EOF
170 170
)"
......
187 187
{
188 188
	echo_func; kw_params cmd; : "${cmd:?}"
189 189
	local a; for a in "$@"; do
190
		a="$(clog++ echo_run "$cmd" "$a")" || return; args+=("$a")
190
		a="$(log++ echo_run "$cmd" "$a")" || return; args+=("$a")
191 191
	done
192 192
	echo_vars args
193 193
}
......
451 451

  
452 452
# usage: in func:      log_local; log++; ...
453 453
#        outside func: log_local; log++; ...; log--
454
#        before cmd:   clog++ cmd  OR  clog+ num cmd  OR  clog++ clog++... cmd
454
#        before cmd:   log++ cmd  OR  log+ num cmd  OR  log++ log++... cmd
455 455
# with a cmd, assignments are applied just to it, so log_local is not needed
456 456
# without a cmd, assignments are applied to caller ("$@" expands to nothing)
457 457
# "${@:2}" expands to all of $@ after *1st* arg, not 2nd ($@ indexes start at 1)
......
467 467
log++() { log+ 1 "$@"; }
468 468
log--() { log- 1 "$@"; }
469 469
log!() { log- "$log_level" "$@"; } # force-displays next log message
470
alias log+='"log+"' # don't expand next word because it's not a cmd
470
alias log+='"log+"' # no last space because next word is not a cmd
471 471
alias log++='"log++" ' # last space alias-expands next word
472 472
alias log--='"log--" ' # last space alias-expands next word
473 473
alias log!='"log!" ' # last space alias-expands next word
474
alias clog+='"log+"' # no last space because next word is not a cmd
475
alias clog++='"log++" ' # last space alias-expands next word
476
alias clog--='"log--" ' # last space alias-expands next word
477
alias clog!='"log!" ' # last space alias-expands next word
478 474

  
479 475
verbosity_min() # usage: verbosity_min {<min>|''}
480 476
# WARNING: '' is a special value that causes $verbosity to be overwritten to ''
......
523 519

  
524 520
bg_r='101;97' # red background with white text
525 521

  
526
log_err() { symbol='#' format="$bg_r" log_fd="$err_fd" clog! log_custom " $1 ";}
522
log_err() { symbol='#' format="$bg_r" log_fd="$err_fd" log! log_custom " $1 ";}
527 523

  
528 524
log_info() { symbol=: log_custom "$@"; }
529 525

  
......
635 631
alias cmd2rel_path="$(cat <<'EOF'
636 632
if test "$(type -t "$1")" = file && test -e "$1"; then # not relative to PATH
637 633
	declare _1="$1"; shift
638
	_1="$(clog++ canon_rel_path "$_1")" || return
634
	_1="$(log++ canon_rel_path "$_1")" || return
639 635
	set -- "$_1" "$@"
640 636
fi
641 637
EOF
......
679 675
	local cmd_name_log_inc="${cmd_name_log_inc-0}"
680 676
	
681 677
	# print <>file redirs before cmd, because they introduce it
682
	clog+ "$cmd_name_log_inc" echo_cmd "$@" $(
678
	log+ "$cmd_name_log_inc" echo_cmd "$@" $(
683 679
		set -- "${redirs[@]}" # operate on ${redirs[@]}
684 680
		while test "$#" -gt 0 && starts_with '[<>][^&]' "$1"
685 681
		do log "$1 \\"; shift; done # log() will run *before* echo_cmd itself
......
737 733
{
738 734
	log_local; log++; can_log || return
739 735
	local func="$1"; shift
740
	local loc; loc="$(clog++ func_loc "$func")" || return
736
	local loc; loc="$(log++ func_loc "$func")" || return
741 737
	echo_cmd "$loc" "$func" "$@"
742 738
}
743 739
# see echo_func alias after stub
......
908 904

  
909 905
set_paths()
910 906
{
911
	top_script="$(clog++ canon_rel_path "$top_script_abs")" || return
907
	top_script="$(log++ canon_rel_path "$top_script_abs")" || return
912 908
		echo_vars top_script
913 909
	top_dir="$(dirname "$top_script")" || return; echo_vars top_dir
914 910
}
......
961 957

  
962 958
.()
963 959
{
964
	clog++ clog++ echo_func
960
	log++ log++ echo_func
965 961
	cmd2rel_path; set -- "$FUNCNAME" "$@"
966 962
	if (log++; echo_params; can_log); then indent; fi
967 963
	builtin "$@"
......
969 965

  
970 966
.rel() # usage: .rel file [args...] # file relative to ${BASH_SOURCE[0]} dir
971 967
{
972
	clog++ clog++ echo_func; local file="$1"; shift
968
	log++ log++ echo_func; local file="$1"; shift
973 969
	. "$(canon_rel_path "$(dirname "$(realpath "${BASH_SOURCE[1]}")")/$file")" \
974 970
"$@"
975 971
}
trunk/lib/sh/db.sh
286 286
	local redirs=("${redirs[@]}" '40<&0' "0<${stdin:-&20}" '41>&1')
287 287
	(
288 288
		# hide stack traces/DETAIL sections of error messages at verbosity <2
289
		if ! clog++ can_log; then echo '\set VERBOSITY terse'; fi
289
		if ! log++ can_log; then echo '\set VERBOSITY terse'; fi
290 290
		if test "$verbose_"; then echo '\timing on'; fi
291 291
		echo "SET client_min_messages = \
292 292
$(if test "$verbose_"; then echo NOTICE; else echo WARNING; fi);"
......
367 367
{
368 368
	echo_func; : "${schema:?}"; mk_schema_esc
369 369
	pattern='cannot create temporary relation in non-temporary schema' \
370
ignore_e=3 clog++ stderr_matches psql <<<"CREATE TEMP TABLE $schema_esc.t ()"
370
ignore_e=3 log++ stderr_matches psql <<<"CREATE TEMP TABLE $schema_esc.t ()"
371 371
}
372 372

  
373 373
pg_require_schema() # usage: schema=... pg_require_schema
......
380 380
{
381 381
	echo_func; : "${table:?}"; mk_table_esc
382 382
	pattern='relation .* does not exist' \
383
ignore_e=3 clog++ stderr_matches psql <<<"SELECT NULL FROM $table_esc LIMIT 0"
383
ignore_e=3 log++ stderr_matches psql <<<"SELECT NULL FROM $table_esc LIMIT 0"
384 384
}
385 385

  
386 386
fi

Also available in: Unified diff