From ef36016ee4412488f1fbf35b9f45190f45287bef Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Fri, 13 Jan 2023 04:02:18 +0100 Subject: [PATCH] armbian-next: logging: reinit logging after processing cmdline parameters - so `DEBUG=yes` actually works --- compile.sh | 2 +- lib/functions/cli/entrypoint.sh | 3 +++ lib/functions/logging/logging.sh | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compile.sh b/compile.sh index 21b000ecd..4fba4bf59 100755 --- a/compile.sh +++ b/compile.sh @@ -39,7 +39,7 @@ fi # shellcheck source=lib/single.sh source "${SRC}"/lib/single.sh -# initialize logging variables. +# initialize logging variables. (this does not consider parameters at this point, only environment variables) logging_init # initialize the traps diff --git a/lib/functions/cli/entrypoint.sh b/lib/functions/cli/entrypoint.sh index 167a003c6..526fa4a5c 100644 --- a/lib/functions/cli/entrypoint.sh +++ b/lib/functions/cli/entrypoint.sh @@ -28,6 +28,9 @@ function cli_entrypoint() { apply_cmdline_params_to_env "early" # which uses ARMBIAN_PARSED_CMDLINE_PARAMS # From here on, no more ${1} or stuff. We've parsed it all into ARMBIAN_PARSED_CMDLINE_PARAMS or ARMBIAN_NON_PARAM_ARGS and ARMBIAN_COMMAND. + # Re-initialize logging, to take into account the new environment after parsing cmdline params. + logging_init + declare -a -g ARMBIAN_CONFIG_FILES=() # fully validated, complete paths to config files. declare -g ARMBIAN_COMMAND_HANDLER="" ARMBIAN_COMMAND="" ARMBIAN_COMMAND_VARS="" # only valid command and handler will ever be set here. declare -g ARMBIAN_HAS_UNKNOWN_ARG="no" # if any unknown params, bomb. diff --git a/lib/functions/logging/logging.sh b/lib/functions/logging/logging.sh index a104f24fc..483c15647 100644 --- a/lib/functions/logging/logging.sh +++ b/lib/functions/logging/logging.sh @@ -1,11 +1,12 @@ #!/usr/bin/env bash +# This is called both early in compile.sh, but also after processing cmdline params in the cli entrypoint.sh function logging_init() { # defaults. # if stdout is a terminal, then default SHOW_LOG to yes [[ -t 1 ]] && declare -g SHOW_LOG="${SHOW_LOG:-"yes"}" - # if DEBUG=yes (via env only, at this point) is set then default both log & debug to yes + # if DEBUG=yes, is set then default both log & debug to yes if [[ "${DEBUG}" == "yes" ]]; then declare -g SHOW_LOG="${SHOW_LOG:-"yes"}" declare -g SHOW_DEBUG="${SHOW_DEBUG:-"yes"}" @@ -14,10 +15,9 @@ function logging_init() { # globals declare -g padding="" left_marker="[" right_marker="]" declare -g normal_color="\x1B[0m" gray_color="\e[1;30m" # "bright black", which is grey - declare -i logging_section_counter=0 # -i: integer - declare -g logging_section_counter - declare -g tool_color="${gray_color}" # default to gray... (should be ok on terminals) - if [[ "${CI}" == "true" ]]; then # ... but that is too dark for Github Actions + declare -g -i logging_section_counter=0 # -i: integer + declare -g tool_color="${gray_color}" # default to gray... (should be ok on terminals, @TODO: I've seen it too dark on a few random screenshots though + if [[ "${CI}" == "true" ]]; then # ... but that is too dark for Github Actions declare -g tool_color="${normal_color}" declare -g SHOW_LOG="${SHOW_LOG:-"yes"}" # if in CI/GHA, default to showing log fi