Browse code

Add a timestamp to the log output for better diagnosis

when we are looking at logs generated by the gate jobs
we need timestamps on the output of stack.sh so we can
figure out what was being executed around the time when
there was a problem in say nova-network

Change-Id: I203e8dae97715d6ee46a4088c7577b9be66cf09d

Davanum Srinivas authored on 2012/12/06 23:47:53
Showing 1 changed files
... ...
@@ -598,7 +598,15 @@ if [[ -n "$LOGFILE" ]]; then
598 598
     exec 3>&1
599 599
     if [[ "$VERBOSE" == "True" ]]; then
600 600
         # Redirect stdout/stderr to tee to write the log file
601
-        exec 1> >( tee "${LOGFILE}" ) 2>&1
601
+        exec 1> >( awk '
602
+                {
603
+                    cmd ="date +\"%Y-%m-%d %H:%M:%S \""
604
+                    cmd | getline now
605
+                    close("date +\"%Y-%m-%d %H:%M:%S \"")
606
+                    sub(/^/, now)
607
+                    print
608
+                    fflush()
609
+                }' | tee "${LOGFILE}" ) 2>&1
602 610
         # Set up a second fd for output
603 611
         exec 6> >( tee "${SUMFILE}" )
604 612
     else