diff --git a/include/dts-environment.sh b/include/dts-environment.sh index 0e0c4e4..f9d9ddb 100644 --- a/include/dts-environment.sh +++ b/include/dts-environment.sh @@ -87,7 +87,6 @@ FW_BACKUP_TAR="${FW_BACKUP_DIR}.tar.gz" FW_BACKUP_TAR="$(echo "$FW_BACKUP_TAR" | sed 's/\ /_/g')" # Paths to system files -ERR_LOG_FILE="/var/local/dts-err.log" FLASHROM_LOG_FILE="/var/local/flashrom.log" FLASH_INFO_FILE="/tmp/flash_info" OS_VERSION_FILE="/etc/os-release" diff --git a/include/dts-functions.sh b/include/dts-functions.sh index 628fbc4..8c4bb1f 100644 --- a/include/dts-functions.sh +++ b/include/dts-functions.sh @@ -84,7 +84,7 @@ fum_exit() { if [ "$FUM" == "fum" ]; then print_error "Update cannot be performed" print_warning "Starting bash session - please make sure you get logs from\r - \r$ERR_LOG_FILE and $FLASHROM_LOG_FILE; then you can poweroff the platform" + \r$ERR_LOG_FILE_REALPATH and $FLASHROM_LOG_FILE; then you can poweroff the platform" /bin/bash fi } @@ -1561,7 +1561,7 @@ footer_options(){ send_dts_logs stop_logging ${CMD_SHELL} - start_logging "$DTS_LOG_FILE" + start_logging # If in submenu before going to shell - return to main menu after exiting # shell: @@ -1608,8 +1608,8 @@ send_dts_logs(){ cp ${DTS_LOG_FILE} $log_dir cp ${DTS_VERBOSE_LOG_FILE} $log_dir - if [ -f ${ERR_LOG_FILE} ]; then - cp ${ERR_LOG_FILE} $log_dir + if [ -f ${ERR_LOG_FILE_REALPATH} ]; then + cp ${ERR_LOG_FILE_REALPATH} $log_dir fi if [ -f ${FLASHROM_LOG_FILE} ]; then diff --git a/scripts/dts-boot b/scripts/dts-boot index 1c58e98..aa57245 100644 --- a/scripts/dts-boot +++ b/scripts/dts-boot @@ -13,18 +13,25 @@ export DTS_ENV="$SBIN_DIR/dts-environment.sh" export DTS_SUBS="$SBIN_DIR/dts-subscription.sh" export DTS_HAL="$SBIN_DIR/dts-hal.sh" export DTS_MOCK_COMMON="$SBIN_DIR/common-mock-func.sh" +export BASH_ENV="$SBIN_DIR/logging" +export ERR_LOG_FILE_REALPATH export DTS_LOG_FILE export DTS_VERBOSE_LOG_FILE -export BASH_ENV="$SBIN_DIR/logging" +export ERR_LOG_FILE export SHELLOPTS +ERR_LOG_FILE_REALPATH="/var/local/dts-err_$(basename "$(tty)").log" DTS_LOG_FILE="/tmp/dts_$(basename "$(tty)").log" DTS_VERBOSE_LOG_FILE="/tmp/dts-verbose_$(basename "$(tty)").log" # shellcheck source=./logging source "$BASH_ENV" -start_trace_logging "${DTS_VERBOSE_LOG_FILE}" -start_logging "${DTS_LOG_FILE}" +start_trace_logging +start_logging +if [ -z "$ERR_LOG_FILE" ]; then + exec {ERR_LOG_FILE}> >(logger >> "$ERR_LOG_FILE_REALPATH") + ERR_LOG_FILE="/proc/$$/fd/$ERR_LOG_FILE" +fi # shellcheck source=../include/dts-environment.sh source $DTS_ENV diff --git a/scripts/logging b/scripts/logging index 8bc1f6d..830d461 100644 --- a/scripts/logging +++ b/scripts/logging @@ -1,5 +1,12 @@ #!/bin/bash +logger() { + while read -r LINE + do + echo "[$(date +%T.%3N)]: $LINE" + done +} + start_logging() { local file="$DTS_LOG_FILE" if [ -z "$LOGGING" ]; then