mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Make add info() log_warn_die.sh and make the subs respect OPT_VERBOSE. Add more test harness subs in util/test-bash-functions.
This commit is contained in:
@@ -27,24 +27,34 @@ set -u
|
||||
PTFUNCNAME=""
|
||||
PTDEBUG="${PTDEBUG:-""}"
|
||||
EXIT_STATUS=0
|
||||
OPT_VERBOSE=${OPT_VERBOSE:-3}
|
||||
|
||||
log() {
|
||||
TS=$(date +%F-%T | tr ':-' '_');
|
||||
_print() {
|
||||
TS=$(date +%F-%T | tr ':-' '_')
|
||||
echo "$TS $*"
|
||||
}
|
||||
|
||||
info() {
|
||||
[ ${OPT_VERBOSE:-0} -ge 3 ] && _print "$*"
|
||||
}
|
||||
|
||||
log() {
|
||||
[ ${OPT_VERBOSE:-0} -ge 2 ] && _print "$*"
|
||||
}
|
||||
|
||||
warn() {
|
||||
log "$*" >&2
|
||||
[ ${OPT_VERBOSE:-0} -ge 1 ] && _print "$*" >&2
|
||||
EXIT_STATUS=1
|
||||
}
|
||||
|
||||
die() {
|
||||
warn "$*"
|
||||
_print "$*" >&2
|
||||
EXIT_STATUS=1
|
||||
exit 1
|
||||
}
|
||||
|
||||
_d () {
|
||||
[ "$PTDEBUG" ] && echo "# $PTFUNCNAME: $(log "$*")" >&2
|
||||
[ "$PTDEBUG" ] && echo "# $PTFUNCNAME: $(_print "$*")" >&2
|
||||
}
|
||||
|
||||
# ###########################################################################
|
||||
|
Reference in New Issue
Block a user