KVM test: kvm_utils.py: add a primitive logging mechanism for kvm_subprocess

Add log_line() which logs a single line to a given file.  The file's path is
given relative to a certain base dir.
Add set_log_dir() which sets the base dir.

This is useful for logging the output of kvm_subprocess.  kvm_subprocess can
take a callback function, which it calls with each line of output it gets from
the running subprocess.  Redirecting kvm_subprocess's output to the regular log
files is done by passing it logging.debug or logging.info.  However, in order
to log to other files, we'd have to pass kvm_subprocess a custom logger method,
e.g. our_custom_logger.debug.  Unfortunately, such methods (called
instancemethods) cannot be pickled, and kvm_subprocess relies on pickling.
This patch offers an easy yet somewhat dirty solution to the problem.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4660 592f7852-d20e-0410-864c-8624ca9c26a4
1 file changed