mirror of
https://github.com/Dasharo/dts-scripts.git
synced 2026-06-13 19:16:21 -07:00
logging: Prefix errors written to 'ERR_LOG_FILE' with timestamp
Combined with trace timestamps it'll be easier to match error to command Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
+10
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user