Log output to /var/log/evocheck.log

This commit is contained in:
William Hirigoyen 2023-02-17 09:52:45 +01:00
parent e5aa1aa323
commit 32d2a94b71
2 changed files with 23 additions and 0 deletions

View file

@ -5,6 +5,8 @@ and this project **does not adhere to [Semantic Versioning](http://semver.org/sp
### Added
* Log output to /var/log/evocheck.log.
### Changed
### Deprecated

View file

@ -100,6 +100,12 @@ is_installed(){
# logging
log() {
msg="${1}"
date=$(/bin/date +"${DATE_FORMAT}")
printf "[%s] %s: %s\\n" "$date" "${PROGNAME}" "${msg}" >> "${LOGFILE}"
}
failed() {
check_name=$1
shift
@ -113,6 +119,9 @@ failed() {
printf "%s FAILED!\n" "${check_name}" >> "${main_output_file}"
fi
fi
# Always log verbose
log "${check_name} FAILED! ${check_comments}"
}
# check functions
@ -1502,6 +1511,13 @@ readonly PROGNAME
ARGS=$@
readonly ARGS
LOGFILE="/var/log/evocheck.log"
readonly LOGFILE
DATE_FORMAT="%Y-%m-%d %H:%M:%S"
# shellcheck disable=SC2034
readonly DATEFORMAT
# Disable LANG*
export LANG=C
export LANGUAGE=C
@ -1560,5 +1576,10 @@ while :; do
shift
done
log "Running $PROGNAME $VERSION..."
# shellcheck disable=SC2086
main ${ARGS}
log "End of $PROGNAME execution."