'Redirect all configured logging StreamHandlers pointing to
old_stream to point to new_stream instead.'

def _redirect_logging_stream_handlers(self, old_stream, new_stream):

    for handler in _current_handlers():
        points_to_stream = (isinstance(handler, logging.StreamHandler) and hasattr(handler.stream, 'fileno') and (handler.stream.fileno() == old_stream.fileno()))
        if points_to_stream:
            logger.removeHandler(handler)
            handler.close()
            new_handler = logging.StreamHandler(new_stream)
            new_handler.setLevel(handler.level)
            new_handler.setFormatter(handler.formatter)
            for log_filter in handler.filters:
                new_handler.addFilter(log_filter)
            logger.addHandler(new_handler)
