This includes several changes to status and console logging:
- SSHHost now turns on console and netconsole logging by default
- autotest writes status logs to status.log instead of just echoing them to stdout
- logging is now unbuffered so that services monitoring the log files see new logs as they come in 

From: John Admanski <jadmanski@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@829 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/autotest.py b/server/autotest.py
index 271443c..5405638 100644
--- a/server/autotest.py
+++ b/server/autotest.py
@@ -236,7 +236,7 @@
 					 section)
 		logfile = "%s/debug/client.log.%d" % (self.results_dir,
 						      section)
-		client_log = open(logfile, 'w')
+		client_log = open(logfile, 'w', 0)
 		if section > 0:
 			cont = '-c'
 		else:
@@ -250,10 +250,13 @@
 				     shell=True,
 				     stdout=client_log,
 				     stderr=subprocess.PIPE)
+		status_log_file = os.path.join(self.results_dir, 'status.log')
+		status_log = open(status_log_file, 'a', 0)
 		line = None
 		for line in iter(p.stderr.readline, ''):
-			print line,
+			sys.stdout.write(line)
 			sys.stdout.flush()
+			status_log.write(line)
 		if not line:
 			raise AutotestRunError("execute_section: %s '%s' \
 			failed to return anything" % (ssh, cmd))
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index 1a0b1b8..04dd960 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -47,8 +47,8 @@
 	SSH_BASE_COMMAND = 'ssh -a'
 
 	def __init__(self, hostname, user="root", port=22, initialize=True,
-		     conmux_log=None, conmux_server=None, conmux_attach=None,
-		     netconsole_log=None, netconsole_port=6666):
+		     conmux_log="console.log", conmux_server=None, conmux_attach=None,
+		     netconsole_log="netconsole.log", netconsole_port=6666):
 		"""
 		Construct a SSHHost object
 		
@@ -148,7 +148,7 @@
 		if logfilename == None:
 			return
 		cmd = ['nc', '-u', '-l', '-p', str(port)]
-		logger = subprocess.Popen(cmd, stdout=open(logfilename, "w"))
+		logger = subprocess.Popen(cmd, stdout=open(logfilename, "a", 0))
 		self.netlogger_pid = logger.pid
 
 
@@ -204,8 +204,9 @@
 			to = '%s/%s' % (self.conmux_server, self.hostname)
 		else:
 			to = self.hostname
-		cmd = [self.conmux_attach, to, 'cat - > %s' % logfilename]
+		cmd = [self.conmux_attach, to, 'cat -']
 		logger = subprocess.Popen(cmd,
+					  stdout=open(logfilename, 'a', 0),
 					  stderr=open('/dev/null', 'w'),
 					  preexec_fn=lambda: os.setpgid(0, 0))
 		self.logger_pid = logger.pid