From cc9de6c03f9b1199f034d8f38a248e7ee9b3e6f7 Mon Sep 17 00:00:00 2001 From: Vangelis Koukis Date: Mon, 17 Oct 2011 11:36:10 +0300 Subject: [PATCH 1/1] Add timestamps in output of run-parts hooks Prepend a timestamp before every line of output of run-parts hooks, needed as a quick-n-dirty way to estimate the time taken by each hook to complete. Refs #1499 --- snf-image-helper/snf-image-helper.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/snf-image-helper/snf-image-helper.in b/snf-image-helper/snf-image-helper.in index 4e6ea31..b42598f 100644 --- a/snf-image-helper/snf-image-helper.in +++ b/snf-image-helper/snf-image-helper.in @@ -71,15 +71,20 @@ fi RUN_PARTS=$(which run-parts) if [ -z "$RUN_PARTS" ]; then - log_error "run-parts programe is missing from the system" + log_error "run-parts program is missing from the system" fi # If something goes wrong with the tasks, try to umount the target filesystem # in case it is left mounted... trap '{ umount "$target"; }' ERR +# Redirect standard error to standard output, +# prepend a timestamp before each line of output. echo "Execute all snf-image tasks...." -$RUN_PARTS -v --exit-on-error "@tasksdir@" +$RUN_PARTS -v --exit-on-error "@tasksdir@" 2>&1| + while IFS= read -r line; do + echo $(date +%Y:%m:%d-%H:%M:%S.%N) "$line" + done # Disable the trap. If code reaches here, the filesystem is unmounted. trap - ERR -- 1.7.10.4