factory_test_init: split output into verbose log and console data

To support subshell execution (ex, gooftool) in a better way,
we should separate "log" and "console info".

This CL makes everything from autotest goes to factory.log, while lines with
"FACTORY" also goes to console for feedback to operators.

This CL must be applied with http://codereview.chromium.org/6736025/.

BUG=chromium-os:13459
TEST=build a factory image and install;
     seeing messages appears in console window.

Change-Id: Ib37250484eeb99e30a5ca29d254f69d7d84594e6

R=tammo@chromium.org,nsanders@chromium.org

Review URL: http://codereview.chromium.org/6733063
diff --git a/factory.conf b/factory.conf
index 9d9826a..1784cba 100644
--- a/factory.conf
+++ b/factory.conf
@@ -20,7 +20,16 @@
   else
     OPT="-c"
   fi
-  ./bin/autotest -t factory $OPT control >>/var/log/factory.log 2>&1
+  FACTORY_LOG_FILE=/var/log/factory.log
+  CONSOLE_LOG_FILE=/var/log/factory_console.log
+  # Factory log will be uploaded so we must always preserve previous results.
+  # Console log is just for UI to display, no need to be saved across sessions;
+  # however in order to support writing by multiple processes, the file must be
+  # opened in "append" mode. So we must first delete it then use >> to append.
+  rm -f "$CONSOLE_LOG_FILE"
+  ./bin/autotest -t factory $OPT control 2>&1 |
+    tee -a "$FACTORY_LOG_FILE" |
+    grep --line-buffer "FACTORY" >>"$CONSOLE_LOG_FILE"
 end script
 
 pre-stop script