'Setup the default logging stream to an internal StringIO instance,
so that we can examine log output as we want.'

def setUp(self):

    logger_dict = logging.getLogger().manager.loggerDict
    logging._acquireLock()
    try:
        self.saved_handlers = logging._handlers.copy()
        self.saved_handler_list = logging._handlerList[:]
        self.saved_loggers = logger_dict.copy()
        self.saved_level_names = logging._levelNames.copy()
    finally:
        logging._releaseLock()
    logging.getLogger('\xab\xd7\xbb')
    logging.getLogger(u'\u013f\xd6G')
    self.root_logger = logging.getLogger('')
    self.original_logging_level = self.root_logger.getEffectiveLevel()
    self.stream = cStringIO.StringIO()
    self.root_logger.setLevel(logging.DEBUG)
    self.root_hdlr = logging.StreamHandler(self.stream)
    self.root_formatter = logging.Formatter(self.log_format)
    self.root_hdlr.setFormatter(self.root_formatter)
    self.root_logger.addHandler(self.root_hdlr)
