'There are some obscure error conditions that can occur when logging is
started twice. See http://twistedmatrix.com/trac/ticket/3289 for more
information.'

def test_startLoggingTwice(self):

    self._startLoggingCleanup()
    sys.stdout = StringIO()
    def showError(eventDict):
        if eventDict['isError']:
            sys.__stdout__.write(eventDict['failure'].getTraceback())
    log.addObserver(showError)
    self.addCleanup(log.removeObserver, showError)
    observer = log.startLogging(sys.stdout)
    self.addCleanup(observer.stop)
    self.assertIsInstance(sys.stdout, LoggingFile)
    fakeStdout = sys.stdout
    observer = log.startLogging(sys.stdout)
    self.assertIs(sys.stdout, fakeStdout)
