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 ### Added
* Log output to /var/log/evocheck.log.
### Changed ### Changed
### Deprecated ### Deprecated

View file

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