Allow an IO object to be passed for log output

This will make testing log output easier because log output can go to a StringIO object