def _startLoggingCleanup(self):
        """
        Cleanup after a startLogging() call that mutates the hell out of some
        global state.
        """
        self.addCleanup(log.theLogPublisher._stopLogging)
        self.addCleanup(setattr, sys, 'stdout', sys.stdout)
        self.addCleanup(setattr, sys, 'stderr', sys.stderr)

        Cleanup after a startLogging() call that mutates the hell out of some
        global state.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_log.py