capturing python logging output to a string buffer