summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions41
1 files changed, 18 insertions, 23 deletions
diff --git a/scripts/functions b/scripts/functions
index 3ba6a3f..66d9ad8 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -13,6 +13,8 @@ CT_OnError() {
CT_DoLog ERROR " called from \"${BASH_SOURCE[${depth}]}\" at line # ${BASH_LINENO[${depth}-1]} in function \"${FUNCNAME[${depth}]}\""
done
CT_DoLog ERROR "Look at \"${CT_ACTUAL_LOG_FILE}\" for more info on this error."
+ CT_STEP_COUNT=1
+ CT_DoEnd ERROR
exit $ret
}
trap CT_OnError ERR
@@ -28,25 +30,6 @@ CT_LOG_LEVEL_EXTRA=3
CT_LOG_LEVEL_DEBUG=4
CT_LOG_LEVEL_ALL=5
-# Attributes
-_A_NOR="\\033[0m"
-_A_BRI="\\033[1m"
-_A_DIM="\\033[2m"
-_A_UND="\\033[4m"
-_A_BRB="\\033[5m"
-_A_REV="\\033[7m"
-_A_HID="\\033[8m"
-
-# Fore colors
-_F_BLK="\\033[30m"
-_F_RED="\\033[31m"
-_F_GRN="\\033[32m"
-_F_YEL="\\033[33m"
-_F_BLU="\\033[34m"
-_F_MAG="\\033[35m"
-_F_CYA="\\033[36m"
-_F_WHI="\\033[37m"
-
# A function to log what is happening
# Different log level are available:
# - ERROR: A serious, fatal error occurred
@@ -84,10 +67,8 @@ CT_DoLog() {
l="`printf \"[%-5s]%*s%s%s\" \"${cur_L}\" \"${indent}\" \" \" \"${line}\"`"
# There will always be a log file, be it /dev/null
echo -e "${l}" >>"${CT_ACTUAL_LOG_FILE}"
- color="CT_${cur_L}_COLOR"
- normal="CT_NORMAL_COLOR"
if [ ${cur_l} -le ${max_level} ]; then
- echo -e "\r${!color}${l}${!normal}"
+ echo -e "\r${l}"
fi
if [ "${CT_LOG_PROGRESS_BAR}" = "y" ]; then
str=`CT_DoDate +%s`
@@ -105,7 +86,21 @@ CT_DoLog() {
return 0
}
-# Abort the execution with a error message
+# Tail message to be logged whatever happens
+# Usage: CT_DoEnd <level>
+CT_DoEnd()
+{
+ CT_STOP_DATE=`CT_DoDate +%s%N`
+ CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
+ CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"
+ elapsed=$((CT_STOP_DATE-CT_STAR_DATE))
+ elapsed_min=$((elapsed/(60*1000*1000*1000)))
+ elapsed_sec=`printf "%02d" $(((elapsed%(60*1000*1000*1000))/(1000*1000*1000)))`
+ elapsed_csec=`printf "%02d" $(((elapsed%(1000*1000*1000))/(10*1000*1000)))`
+ CT_DoLog INFO "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
+}
+
+# Abort the execution with an error message
# Usage: CT_Abort <message>
CT_Abort() {
CT_DoLog ERROR "$1" >&2