From 813801add25896afc4bd9839f5d1fe0c05eea465 Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Sat, 2 Jan 2016 14:20:31 +0100 Subject: [PATCH] Proper timestamps in the logs --- config/debian/common | 6 +++--- config/debian/cron.reboot | 2 +- config/debian/dinstall.variables | 2 +- config/debian/hourly.functions | 2 +- config/debian/vars | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/debian/common b/config/debian/common index bc3248c7..0754159e 100644 --- a/config/debian/common +++ b/config/debian/common @@ -4,7 +4,7 @@ # Set $PROGRAM to a string to have it added to the output. function log () { local prefix=${PROGRAM:-} - echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${prefix}[$$]: $@" + echo "$(date +"%b %d %H:%M:%S") ${HOSTNAME} ${prefix}[$$]: $@" } # log the message using log() but then also send a mail @@ -12,7 +12,7 @@ function log () { function log_error () { log "$@" if [ -z "${MAILTO}" ]; then - echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" -a "From: Debian FTP Masters " ${MAILTO} + echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@${HOSTNAME}] ERROR [$$]" -a "From: Debian FTP Masters " ${MAILTO} fi } @@ -347,7 +347,7 @@ function stage() { # Now we should make sure that we have a usable ${PROGRAM}.log, so # append the $STAGEFILE.log to it. - cat "${STAGEFILE}.log" >> "${LOGFILE}" + /usr/bin/ts "%b %d %H:%M:%S ${HOSTNAME} ${PROGRAM}[$$]: ${FUNC} " < "${STAGEFILE}.log" rm -f "${STAGEFILE}.log" log "########## ${PROGRAM} END: ${FUNC} ##########" diff --git a/config/debian/cron.reboot b/config/debian/cron.reboot index 78c0e9ba..dc802dc2 100755 --- a/config/debian/cron.reboot +++ b/config/debian/cron.reboot @@ -45,7 +45,7 @@ DEBUG=0 PROGRAM="dinstall_reboot" # where do we want mails to go? For example log entries made with error() -if [ "x$(hostname -s)x" != "xfranckx" ]; then +if [[ ${HOSTNAME} != franck ]]; then # Not our ftpmaster host MAILTO=${MAILTO:-"root"} else diff --git a/config/debian/dinstall.variables b/config/debian/dinstall.variables index 09258819..2587b2a8 100644 --- a/config/debian/dinstall.variables +++ b/config/debian/dinstall.variables @@ -3,7 +3,7 @@ DEBUG=0 # where do we want mails to go? For example log entries made with error() -if [ "x$(hostname -s)x" != "xfranckx" ]; then +if [[ ${HOSTNAME} != franck ]]; then # Not our ftpmaster host MAILTO=${MAILTO:-"root"} else diff --git a/config/debian/hourly.functions b/config/debian/hourly.functions index 6c1b093c..5ba90853 100644 --- a/config/debian/hourly.functions +++ b/config/debian/hourly.functions @@ -67,7 +67,7 @@ function builddautosigning() { exec >>/dev/null 2>&1 DATE=$(date -Is) - cat "${BUILDDFUN}" | mail -a "X-Debian: DAK" -e -s "[$(hostname -s)] Buildd key changes ${DATE}" -a "From: Debian FTP Masters " buildd-keys@ftp-master.debian.org + cat "${BUILDDFUN}" | mail -a "X-Debian: DAK" -e -s "[${HOSTNAME}] Buildd key changes ${DATE}" -a "From: Debian FTP Masters " buildd-keys@ftp-master.debian.org rm -f "${BUILDDFUN}" } diff --git a/config/debian/vars b/config/debian/vars index eb240572..d134d9c4 100644 --- a/config/debian/vars +++ b/config/debian/vars @@ -46,6 +46,7 @@ LOCK_STOP="${lockdir}/archive.stop" # And the following types of cronscripts exists declare -lr POSSIBLEARGS='+(unchecked|dinstall|hourly|daily|weekly|monthly|yearly)' +declare -r HOSTNAME=$(hostname -s) archs=$(dak admin a list | tr '\n' ' ') -- 2.39.2