diff --git a/client/docker-finance.d/client/env/gen.bash b/client/docker-finance.d/client/env/gen.bash index 2b16d25..8841e99 100644 --- a/client/docker-finance.d/client/env/gen.bash +++ b/client/docker-finance.d/client/env/gen.bash @@ -31,8 +31,8 @@ export DOCKER_FINANCE_VERSION="$global_client_version" # Developer related -if [ -z "$DOCKER_FINANCE_DEBUG" ]; then - export DOCKER_FINANCE_DEBUG=false +if [[ -z "$DOCKER_FINANCE_DEBUG" || ! "$DOCKER_FINANCE_DEBUG" =~ ^0$|^1$|^2$ ]]; then + export DOCKER_FINANCE_DEBUG=0 fi # Allows transparent r/w of mounted volumes diff --git a/client/src/docker/completion.bash b/client/src/docker/completion.bash index 1ee4cce..100e1ee 100644 --- a/client/src/docker/completion.bash +++ b/client/src/docker/completion.bash @@ -18,14 +18,15 @@ # along with this program. If not, see . # WARNING: because of completion, the docker-finance environment file -# is never read. Ergo, for debugging, you'll need to run the following: +# is never read. Ergo, for debugging, you'll need to run the following +# with log-level 1 or 2: # -# `export DOCKER_FINANCE_DEBUG=true && . ~/.bashrc` +# `export DOCKER_FINANCE_DEBUG=2 && . ~/.bashrc` # # and then proceed to call `docker-finance` / `dfi` with your commands. # shellcheck disable=SC2154 -[ "$DOCKER_FINANCE_DEBUG" == true ] && set -xv +[ "$DOCKER_FINANCE_DEBUG" == 2 ] && set -xv # If not yet installed, gracefully exit if ! hash docker &>/dev/null; then diff --git a/client/src/docker/docker.bash b/client/src/docker/docker.bash index e64f1a5..d4d1d31 100755 --- a/client/src/docker/docker.bash +++ b/client/src/docker/docker.bash @@ -161,7 +161,7 @@ function main() lib_docker::docker "$@" || lib_utils::die_usage "$_usage" # shellcheck disable=SC2154 - [ "$DOCKER_FINANCE_DEBUG" == true ] && set -xv + [ "$DOCKER_FINANCE_DEBUG" == 2 ] && set -xv # # Command facade diff --git a/container/src/finance/completion.bash b/container/src/finance/completion.bash index 14b7658..e1ec34a 100644 --- a/container/src/finance/completion.bash +++ b/container/src/finance/completion.bash @@ -18,7 +18,7 @@ # along with this program. If not, see . # shellcheck disable=SC2154 -[ "$DOCKER_FINANCE_DEBUG" == true ] && set -xv +[ "$DOCKER_FINANCE_DEBUG" == 2 ] && set -xv [ -z "$DOCKER_FINANCE_CONTAINER_FLOW" ] && exit 1 diff --git a/container/src/finance/finance.bash b/container/src/finance/finance.bash index e36bddf..97eac62 100755 --- a/container/src/finance/finance.bash +++ b/container/src/finance/finance.bash @@ -94,7 +94,7 @@ function main() lib_finance::finance "$@" || lib_utils::die_usage "$_usage" # shellcheck disable=SC2154 - [ "$DOCKER_FINANCE_DEBUG" == true ] && set -xv + [ "$DOCKER_FINANCE_DEBUG" == 2 ] && set -xv # # Facade commands diff --git a/container/src/finance/lib/internal/fetch/utils/utils.php b/container/src/finance/lib/internal/fetch/utils/utils.php index c2abbe1..5d64549 100644 --- a/container/src/finance/lib/internal/fetch/utils/utils.php +++ b/container/src/finance/lib/internal/fetch/utils/utils.php @@ -91,7 +91,7 @@ namespace docker_finance\utils public static function print_debug(mixed $message): void { - if (getenv('DOCKER_FINANCE_DEBUG') == "true") { + if (preg_match('/^1$|^2$/', getenv('DOCKER_FINANCE_DEBUG'))) { $bt = debug_backtrace(); fwrite(STDERR, "\e[33m[DEBUG] {$bt[1]['file']}:{$bt[1]['line']} -> {$bt[1]['function']} -> "); diff --git a/container/src/finance/lib/internal/lib_utils.bash b/container/src/finance/lib/internal/lib_utils.bash index 82e0bdd..cec114b 100644 --- a/container/src/finance/lib/internal/lib_utils.bash +++ b/container/src/finance/lib/internal/lib_utils.bash @@ -54,7 +54,7 @@ function lib_utils::print_fatal() function lib_utils::print_debug() { # shellcheck disable=SC2154 - if [[ "$DOCKER_FINANCE_DEBUG" == true ]]; then + if [[ "$DOCKER_FINANCE_DEBUG" =~ ^1$|^2$ ]]; then local _debug="${BASH_SOURCE[1]##*/}:${BASH_LINENO[0]} -> ${FUNCNAME[1]}" lib_utils::__print "\e[33m" "[DEBUG] ${_debug} -> $*" else