Added ALWAYS loger option, also fixed boolean capitalization
This commit is contained in:
parent
8ccad34d01
commit
4fb0b5f5f7
|
@ -1,14 +1,15 @@
|
||||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
|
|
||||||
## FUNC_BUILD=2016111401
|
## FUNC_BUILD=2016111402
|
||||||
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
||||||
|
|
||||||
## To use in a program, define the following variables:
|
## To use in a program, define the following variables:
|
||||||
## PROGRAM=program-name
|
## PROGRAM=program-name
|
||||||
## INSTANCE_ID=program-instance-name
|
## INSTANCE_ID=program-instance-name
|
||||||
## _DEBUG=yes/no
|
## _DEBUG=yes/no
|
||||||
## _LOGGER_STDERR=True/False
|
## _LOGGER_STDERR=true/False
|
||||||
## _LOGGER_ERR_ONLY=True/False
|
## _LOGGER_ERR_ONLY=true/False
|
||||||
|
## _LOGGER_PREFIX="date"/"time"/""
|
||||||
|
|
||||||
#TODO: Windows checks, check sendmail & mailsend
|
#TODO: Windows checks, check sendmail & mailsend
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ function Logger {
|
||||||
WARN_ALERT=true
|
WARN_ALERT=true
|
||||||
return
|
return
|
||||||
elif [ "$level" == "NOTICE" ]; then
|
elif [ "$level" == "NOTICE" ]; then
|
||||||
if [ "$_LOGGER_ERR_ONLY" != True ]; then
|
if [ "$_LOGGER_ERR_ONLY" != true ]; then
|
||||||
_Logger "$prefix$value"
|
_Logger "$prefix$value"
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
|
@ -153,6 +154,11 @@ function Logger {
|
||||||
_Logger "$prefix$value"
|
_Logger "$prefix$value"
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
|
elif [ "$level" == "ALWAYS" ]; then
|
||||||
|
if [ $_SILENT != true ]; then
|
||||||
|
_Logger "$prefix$value" "$prefix$level:$value" "$level:$value"
|
||||||
|
fi
|
||||||
|
return
|
||||||
elif [ "$level" == "DEBUG" ]; then
|
elif [ "$level" == "DEBUG" ]; then
|
||||||
if [ "$_DEBUG" == "yes" ]; then
|
if [ "$_DEBUG" == "yes" ]; then
|
||||||
_Logger "$prefix$value"
|
_Logger "$prefix$value"
|
||||||
|
@ -278,7 +284,7 @@ function SendAlert {
|
||||||
Logger "Cannot create [$ALERT_LOG_FILE]" "WARN"
|
Logger "Cannot create [$ALERT_LOG_FILE]" "WARN"
|
||||||
attachment=False
|
attachment=False
|
||||||
else
|
else
|
||||||
attachment=True
|
attachment=true
|
||||||
fi
|
fi
|
||||||
body="$MAIL_ALERT_MSG"$'\n\n'"$CURRENT_LOG"
|
body="$MAIL_ALERT_MSG"$'\n\n'"$CURRENT_LOG"
|
||||||
|
|
||||||
|
@ -296,14 +302,14 @@ function SendAlert {
|
||||||
subject="Fnished run - $subject"
|
subject="Fnished run - $subject"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$attachment" == True ]; then
|
if [ "$attachment" == true ]; then
|
||||||
attachmentFile="$ALERT_LOG_FILE"
|
attachmentFile="$ALERT_LOG_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SendEmail "$subject" "$body" "$DESTINATION_MAILS" "$attachmentFile" "$SENDER_MAIL" "$SMTP_SERVER" "$SMTP_PORT" "$ENCRYPTION" "SMTP_USER" "$SMTP_PASSWORD"
|
SendEmail "$subject" "$body" "$DESTINATION_MAILS" "$attachmentFile" "$SENDER_MAIL" "$SMTP_SERVER" "$SMTP_PORT" "$ENCRYPTION" "SMTP_USER" "$SMTP_PASSWORD"
|
||||||
|
|
||||||
# Delete tmp log file
|
# Delete tmp log file
|
||||||
if [ "$attachment" == True ]; then
|
if [ "$attachment" == true ]; then
|
||||||
if [ -f "$ALERT_LOG_FILE" ]; then
|
if [ -f "$ALERT_LOG_FILE" ]; then
|
||||||
rm -f "$ALERT_LOG_FILE"
|
rm -f "$ALERT_LOG_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue