'Set up a TCP server to receive log messages, and a SocketHandler
pointing to that server\'s address and port.'

def setUp(self):

    BaseTest.setUp(self)
    self.tcpserver = LogRecordSocketReceiver(port=0)
    self.port = self.tcpserver.socket.getsockname()[1]
    self.threads = [threading.Thread(target=self.tcpserver.serve_until_stopped)]
    for thread in self.threads:
        thread.start()
    self.sock_hdlr = logging.handlers.SocketHandler('localhost', self.port)
    self.sock_hdlr.setFormatter(self.root_formatter)
    self.root_logger.removeHandler(self.root_logger.handlers[0])
    self.root_logger.addHandler(self.sock_hdlr)
