'Emit a record.'

def emit(self, record):

    try:
        stream = cherrypy.serving.request.wsgi_environ.get('wsgi.errors')
    except (AttributeError, KeyError):
        pass
    else:
        try:
            msg = self.format(record)
            fs = '%s\n'
            import types
            if (not hasattr(types, 'UnicodeType')):
                stream.write((fs % msg))
            else:
                try:
                    stream.write((fs % msg))
                except UnicodeError:
                    stream.write((fs % msg.encode('UTF-8')))
            self.flush()
        except:
            self.handleError(record)
