[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] 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 bc3248c..0754159 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 <ftpmaster@ftp-master.debian.org>" ${MAILTO}
+        echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@${HOSTNAME}] ERROR [$$]" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" ${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 78c0e9b..dc802dc 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 0925881..2587b2a 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 6c1b093..5ba9085 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 <ftpmaster@ftp-master.debian.org>" 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 <ftpmaster@ftp-master.debian.org>" buildd-keys@ftp-master.debian.org
 
     rm -f "${BUILDDFUN}"
 }
diff --git a/config/debian/vars b/config/debian/vars
index eb24057..d134d9c 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.1.4


Reply to: