mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
armbian-next: logging: reinit logging after processing cmdline parameters
- so `DEBUG=yes` actually works
This commit is contained in:
@@ -39,7 +39,7 @@ fi
|
|||||||
# shellcheck source=lib/single.sh
|
# shellcheck source=lib/single.sh
|
||||||
source "${SRC}"/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
|
logging_init
|
||||||
|
|
||||||
# initialize the traps
|
# initialize the traps
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ function cli_entrypoint() {
|
|||||||
apply_cmdline_params_to_env "early" # which uses ARMBIAN_PARSED_CMDLINE_PARAMS
|
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.
|
# 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 -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_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.
|
declare -g ARMBIAN_HAS_UNKNOWN_ARG="no" # if any unknown params, bomb.
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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() {
|
function logging_init() {
|
||||||
# defaults.
|
# defaults.
|
||||||
# if stdout is a terminal, then default SHOW_LOG to yes
|
# if stdout is a terminal, then default SHOW_LOG to yes
|
||||||
[[ -t 1 ]] && declare -g SHOW_LOG="${SHOW_LOG:-"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
|
if [[ "${DEBUG}" == "yes" ]]; then
|
||||||
declare -g SHOW_LOG="${SHOW_LOG:-"yes"}"
|
declare -g SHOW_LOG="${SHOW_LOG:-"yes"}"
|
||||||
declare -g SHOW_DEBUG="${SHOW_DEBUG:-"yes"}"
|
declare -g SHOW_DEBUG="${SHOW_DEBUG:-"yes"}"
|
||||||
@@ -14,10 +15,9 @@ function logging_init() {
|
|||||||
# globals
|
# globals
|
||||||
declare -g padding="" left_marker="[" right_marker="]"
|
declare -g padding="" left_marker="[" right_marker="]"
|
||||||
declare -g normal_color="\x1B[0m" gray_color="\e[1;30m" # "bright black", which is grey
|
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 -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, @TODO: I've seen it too dark on a few random screenshots though
|
||||||
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
|
||||||
if [[ "${CI}" == "true" ]]; then # ... but that is too dark for Github Actions
|
|
||||||
declare -g tool_color="${normal_color}"
|
declare -g tool_color="${normal_color}"
|
||||||
declare -g SHOW_LOG="${SHOW_LOG:-"yes"}" # if in CI/GHA, default to showing log
|
declare -g SHOW_LOG="${SHOW_LOG:-"yes"}" # if in CI/GHA, default to showing log
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user