def test_logFormatOverride(self):
        """
        If the factory is initialized with a custom log formatter then that
        formatter is used to generate lines for the log file.
        """
        def notVeryGoodFormatter(timestamp, request):
            return u"this is a bad log format"

        reactor = Clock()
        reactor.advance(1234567890)

        logPath = self.mktemp()
        factory = self.factory(
            logPath=logPath, logFormatter=notVeryGoodFormatter)
        factory._reactor = reactor
        factory.startFactory()
        try:
            factory.log(DummyRequestForLogTest(factory))
        finally:
            factory.stopFactory()

        self.assertEqual(
            b"this is a bad log format\n",
            FilePath(logPath).getContent())

        If the factory is initialized with a custom log formatter then that
        formatter is used to generate lines for the log file.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_web.py