def _makeObserver(self):
        """
        Make a new observer which captures all logs sent to it.

        @return: An observer that stores all logs sent to it.
        @rtype: Callable that implements L{ILogObserver}.
        """
        @implementer(ILogObserver)
        class TestObserver(object):
            _logs = []

            def __call__(self, event):
                self._logs.append(event)

        return TestObserver()

        Make a new observer which captures all logs sent to it.

        @return: An observer that stores all logs sent to it.
        @rtype: Callable that implements L{ILogObserver}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_twistd.py