Browse Source

Made messages consistent with new exitcode format

pull/914/head
Daniel Gibbs 9 years ago
parent
commit
ea17d3bd96
  1. 195
      lgsm/functions/core_messages.sh

195
lgsm/functions/core_messages.sh

@ -7,112 +7,139 @@
# nl: new line: message is following by a new line
# eol: end of line: message is placed at the end of the current line
# Date, servicename & module details displayed in log files.
# e.g Feb 28 14:56:58 ut99-server: Monitor:
# Log display
##########
## Feb 28 14:56:58 ut99-server: Monitor:
fn_script_log(){
if [ -n "${modulename}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ${1}" >> "${scriptlog}"
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
fi
}
## Feb 28 14:56:58 ut99-server: Monitor: PASS:
fn_script_log_pass(){
if [ -n "${modulename}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: PASS: ${1}" >> "${scriptlog}"
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: PASS: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: PASS: ${1}" >> "${scriptlog}"
fi
exitcode=0
}
## Feb 28 14:56:58 ut99-server: Monitor: FATAL:
fn_script_log_fatal(){
if [ -n "${modulename}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: FATAL: ${1}" >> "${scriptlog}"
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: FATAL: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: FATAL: ${1}" >> "${scriptlog}"
fi
exitcode=1
}
## Feb 28 14:56:58 ut99-server: Monitor: ERROR:
fn_script_log_error(){
if [ -n "${modulename}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ERROR: ${1}" >> "${scriptlog}"
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: ERROR: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ERROR: ${1}" >> "${scriptlog}"
fi
exitcode=2
}
## Feb 28 14:56:58 ut99-server: Monitor: WARN:
fn_script_log_warn(){
if [ -n "${modulename}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: WARN: ${1}" >> "${scriptlog}"
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: WARN: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: WARN: ${1}" >> "${scriptlog}"
fi
exitcode=3
}
## Feb 28 14:56:58 ut99-server: Monitor: INFO:
fn_script_log_info(){
if [ -n "${modulename}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: INFO: ${1}" >> "${scriptlog}"
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: INFO: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: INFO: ${1}" >> "${scriptlog}"
fi
}
# [ FAIL ]
fn_print_fail(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@"
# On-Screen
##########
# [ .... ]
fn_print_dots(){
if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[ .... ] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@"
echo -en "\r\033[K[ .... ] $@"
fi
}
fn_print_fail_nl(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@"
fn_print_dots_nl(){
if [ -n "${commandaction}" ]; then
echo -e "\r\033[K[ .... ] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@"
echo -e "\r\033[K[ .... ] $@"
fi
sleep 1
echo -en "\n"
}
# [ OK ]
fn_print_ok(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@"
if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[0;32m OK \e[0m] $@"
fi
}
fn_print_ok_nl(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@"
if [ -n "${commandaction}" ]; then
echo -e "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[0;32m OK \e[0m] $@"
echo -e "\r\033[K[\e[0;32m OK \e[0m] $@"
fi
sleep 1
echo -en "\n"
}
# [ INFO ]
fn_print_info(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@"
# [ FAIL ]
fn_print_fail(){
if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@"
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@"
fi
}
fn_print_info_nl(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@"
fn_print_fail_nl(){
if [ -n "${commandaction}" ]; then
echo -e "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@"
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@"
fi
sleep 1
echo -en "\n"
}
# [ ERROR ]
fn_print_error(){
if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[0;31m ERROR \e[0m] $@"
fi
}
fn_print_error_nl(){
if [ -n "${commandaction}" ]; then
echo -e "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@"
else
echo -e "\r\033[K[\e[0;31m ERROR \e[0m] $@"
fi
sleep 1
echo -en "\n"
@ -120,32 +147,45 @@ fn_print_info_nl(){
# [ WARN ]
fn_print_warn(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@"
if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@"
fi
}
fn_print_warn_nl(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@"
if [ -n "${commandaction}" ]; then
echo -e "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@"
echo -e "\r\033[K[\e[1;33m WARN \e[0m] $@"
fi
sleep 1
echo -en "\n"
}
# [ .... ]
fn_print_dots(){
if [ -n "${modulename}" ]; then
echo -en "\r\033[K[ .... ] ${modulename} ${servicename}: $@"
# [ INFO ]
fn_print_info(){
if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@"
else
echo -en "\r\033[K[ .... ] $@"
echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@"
fi
}
fn_print_info_nl(){
if [ -n "${commandaction}" ]; then
echo -e "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@"
else
echo -e "\r\033[K[\e[0;36m INFO \e[0m] $@"
fi
sleep 1
echo -en "\n"
}
# On-Screen full word
##########
# Complete!
fn_print_complete(){
echo -en "\e[0;32mComplete!\e[0m $@"
@ -155,15 +195,6 @@ fn_print_complete_nl(){
echo -e "\e[0;32mComplete!\e[0m $@"
}
# Warning!
fn_print_warning(){
echo -en "\e[0;33mWarning!\e[0m $@"
}
fn_print_warning_nl(){
echo -e "\e[0;33mWarning!\e[0m $@"
}
# Failure!
fn_print_failure(){
echo -en "\e[0;31mFailure!\e[0m $@"
@ -182,6 +213,15 @@ fn_print_error_nl(){
echo -e "\e[0;31mError!\e[0m $@"
}
# Warning!
fn_print_warning(){
echo -en "\e[0;33mWarning!\e[0m $@"
}
fn_print_warning_nl(){
echo -e "\e[0;33mWarning!\e[0m $@"
}
# Infomation!
fn_print_infomation(){
echo -en "\e[0;36mInfomation!\e[0m $@"
@ -191,7 +231,10 @@ fn_print_infomation_nl(){
echo -e "\e[0;36mInfomation!\e[0m $@"
}
# FAIL for end of line
# On-Screen End of Line
##########
# OK
fn_print_ok_eol(){
echo -en "\e[0;32mOK\e[0m"
}
@ -200,7 +243,7 @@ fn_print_ok_eol_nl(){
echo -e "\e[0;32mOK\e[0m"
}
# FAIL for end of line
# FAIL
fn_print_fail_eol(){
echo -en "\e[0;31mFAIL\e[0m"
}
@ -209,7 +252,25 @@ fn_print_fail_eol_nl(){
echo -e "\e[0;31mFAIL\e[0m"
}
# QUERYING for end of line
# WARN
fn_print_warn_eol(){
echo -en "\e[0;31mFAIL\e[0m"
}
fn_print_warn_eol_nl(){
echo -e "\e[0;31mFAIL\e[0m"
}
# INFO
fn_print_info_eol(){
echo -en "\e[0;31mFAIL\e[0m"
}
fn_print_info_eol_nl(){
echo -e "\e[0;31mFAIL\e[0m"
}
# QUERYING
fn_print_querying_eol(){
echo -en "\e[0;36mQUERYING\e[0m"
}
@ -218,7 +279,7 @@ fn_print_querying_eol_nl(){
echo -e "\e[0;36mQUERYING\e[0m"
}
# CHECKING for end of line
# CHECKING
fn_print_checking_eol(){
echo -en "\e[0;36mCHECKING\e[0m"
}
@ -227,7 +288,7 @@ fn_print_checking_eol_nl(){
echo -e "\e[0;36mCHECKING\e[0m"
}
# CANCELED for end of line
# CANCELED
fn_print_canceled_eol(){
echo -en "\e[0;33mCANCELED\e[0m"
}
@ -236,7 +297,7 @@ fn_print_canceled_eol_nl(){
echo -e "\e[0;33mCANCELED\e[0m"
}
# REMOVED for end of line
# REMOVED
fn_print_removed_eol(){
echo -en "\e[0;31mREMOVED\e[0m"
}
@ -245,13 +306,11 @@ fn_print_removed_eol_nl(){
echo -e "\e[0;31mREMOVED\e[0m"
}
# UPDATE for end of line
# UPDATE
fn_print_update_eol(){
echo -en "\e[0;36mUPDATE\e[0m"
}
fn_print_update_eol_nl(){
echo -e "\e[0;36mUPDATE\e[0m"
}
}
Loading…
Cancel
Save