From 02b196d0c2e9d545534d4fd9090b150687dacaa5 Mon Sep 17 00:00:00 2001 From: Bernhard Landauer Date: Wed, 22 Feb 2017 10:21:08 +0100 Subject: [PATCH] fix errorlog --- lib/util.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/util.sh b/lib/util.sh index fe5903a..8ce22e3 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -144,22 +144,24 @@ id_system() { } # If there is an error, display it and go back to main menu. In any case, write to logfile. +# param 2 : error code is optional check_for_error() { - local _msg="[$1]" - local _err="$2" + local _msg="$1" + local _err="${2:-0}" + ((${_err}!=0)) && _msg="[${_msg}][${_err}]" [[ -f "${ERR}" ]] && { - _msg="${_msg}: $(head -n1 ${ERR})" + _msg="${_msg} $(head -n1 ${ERR})" rm "${ERR}" } - if ((${_err}==1)); then - _msg="ERROR: ${_msg}" - DIALOG " $_ErrTitle " --msgbox "\n$(cat ${ERR})\n" 0 0 - # and function for varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" + if ((${_err}!=0)); then + # and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" + echo -e "$(date +%D\ %T) ERROR ${_msg}" >> "${LOGFILE}" + DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0 main_menu_online else - _msg="##${_msg}" + echo -e "$(date +%D\ %T) ${_msg}" >> "${LOGFILE}" fi - echo -e "$(date +%D\ %T\ %Z) ${_msg}" >> "${LOGFILE}" + } # Add locale on-the-fly and sets source translation file for installer