armbian-next: fix ANSI logs, use reset at strategic places

This commit is contained in:
Ricardo Pardini
2023-01-21 18:54:03 +01:00
parent eb30aac310
commit d95478281b
2 changed files with 6 additions and 5 deletions

View File

@@ -49,13 +49,13 @@ function export_ansi_logs() {
display_alert "Preparing ANSI log from" "${LOGDIR}" "debug" display_alert "Preparing ANSI log from" "${LOGDIR}" "debug"
declare dim_line_separator declare dim_line_separator
dim_line_separator=$(echo -e -n "${gray_color:-}")------------------------------------------------------------------------------------------------------------$(echo -e -n "${normal_color:-}") dim_line_separator=$(echo -e -n "${gray_color:-}")------------------------------------------------------------------------------------------------------------$(echo -e -n "${ansi_reset_color:-}")
cat <<- ANSI_HEADER > "${target_file}" cat <<- ANSI_HEADER > "${target_file}"
# Armbian ANSI build logs for ${ARMBIAN_BUILD_UUID} - use "less -SR" to view # Armbian ANSI build logs for ${ARMBIAN_BUILD_UUID} - use "less -SR" to view
$(echo -e -n "${bright_blue_color}")# Armbian build at $(LC_ALL=C LANG=C date) on $(hostname || true) $(echo -e -n "${bright_blue_color:-}")# Armbian build at $(LC_ALL=C LANG=C date) on $(hostname || true)$(echo -e -n "${ansi_reset_color}")
${dim_line_separator} ${dim_line_separator}
$(echo -e -n "${bright_blue_color}")# ARGs: ${ARMBIAN_ORIGINAL_ARGV[@]@Q} $(echo -e -n "${bright_blue_color}")# ARGs: ${ARMBIAN_ORIGINAL_ARGV[@]@Q}$(echo -e -n "${ansi_reset_color}")
${dim_line_separator} ${dim_line_separator}
ANSI_HEADER ANSI_HEADER
@@ -80,7 +80,7 @@ function export_ansi_logs() {
declare -a logfiles_array declare -a logfiles_array
mapfile -t logfiles_array < <(find "${LOGDIR}" -type f | LC_ALL=C sort -h) # "human" sorting mapfile -t logfiles_array < <(find "${LOGDIR}" -type f | LC_ALL=C sort -h) # "human" sorting
prefix_sed_contents=" $(echo -n -e "${tool_color:-}")" # spaces are significant prefix_sed_contents=" $(echo -n -e "${ansi_reset_color}${tool_color:-}")" # spaces are significant
declare prefix_sed_cmd="/^-->/!s/^/${prefix_sed_contents}/;" declare prefix_sed_cmd="/^-->/!s/^/${prefix_sed_contents}/;"
declare logfile_full declare logfile_full
@@ -95,7 +95,7 @@ function export_ansi_logs() {
logfile_title="$(echo "${logfile_base}" | sed -e 's/^[^.]*\.[^.]*\.//')" logfile_title="$(echo "${logfile_base}" | sed -e 's/^[^.]*\.[^.]*\.//')"
cat <<- ANSI_ONE_LOGFILE >> "${target_file}" cat <<- ANSI_ONE_LOGFILE >> "${target_file}"
$(echo -e -n "${bright_blue_color}")### ${logfile_title} $(echo -e -n "${normal_color}") $(echo -e -n "${bright_blue_color}")### ${logfile_title} $(echo -e -n "${ansi_reset_color}")
$(cat "${logfile_full}" | sed -e "${prefix_sed_cmd}") $(cat "${logfile_full}" | sed -e "${prefix_sed_cmd}")
${dim_line_separator} ${dim_line_separator}
ANSI_ONE_LOGFILE ANSI_ONE_LOGFILE

View File

@@ -18,6 +18,7 @@ function logging_init() {
declare -g bright_red_color="\e[1;31m" red_color="\e[0;31m" declare -g bright_red_color="\e[1;31m" red_color="\e[0;31m"
declare -g bright_blue_color="\e[1;34m" blue_color="\e[0;34m" declare -g bright_blue_color="\e[1;34m" blue_color="\e[0;34m"
declare -g bright_magenta_color="\e[1;35m" magenta_color="\e[0;35m" declare -g bright_magenta_color="\e[1;35m" magenta_color="\e[0;35m"
declare -g ansi_reset_color="\e[0m"
declare -g -i logging_section_counter=0 # -i: integer 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 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 if [[ "${CI}" == "true" ]]; then # ... but that is too dark for Github Actions