1 # log something (basically echo it together with a timestamp)
3 # Set $PROGRAM to a string to have it added to the output.
5 if [ -z "${PROGRAM}" ]; then
6 echo "$(date +"%b %d %H:%M:%S") $(hostname -s) [$$] $@"
8 echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${PROGRAM}[$$]: $@"
12 # log the message using log() but then also send a mail
13 # to the address configured in MAILTO (if non-empty)
14 function log_error () {
16 if [ -z "${MAILTO}" ]; then
17 echo "$@" | mail -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" ${MAILTO}
21 # debug log, only output when DEBUG=1
23 if [ $DEBUG -eq 1 ]; then