def write(self, data):
        """
        Generate an event for the logging system with the given bytes as the
        message.

        This is called in a WSGI application thread, not the I/O thread.

        @type data: str

        @raise TypeError: On Python 3, if C{data} is not a native string. On
            Python 2 a warning will be issued.
        """
        if not isinstance(data, str):
            if str is bytes:
                warn("write() argument should be str, not %r (%s)" % (
                    data, type(data).__name__), category=UnicodeWarning)
            else:
                raise TypeError(
                    "write() argument must be str, not %r (%s)"
                    % (data, type(data).__name__))

        # Note that in old style, message was a tuple.  logger._legacy
        # will overwrite this value if it is not properly formatted here.
        self._log.error(
            data,
            system='wsgi',
            isError=True,
            message=(data,)
        )

        Generate an event for the logging system with the given bytes as the
        message.

        This is called in a WSGI application thread, not the I/O thread.

        @type data: str

        @raise TypeError: On Python 3, if C{data} is not a native string. On
            Python 2 a warning will be issued.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/wsgi.py