def emit(self, record):
        """Emit a record"""
        try:
            stream = self.get_wsgierrors()
        except TypeError:
            pass
        else:
            if not stream:
                return
            try:
                msg = self.format(record)
                fs = "%s\n"
                if not hasattr(types, "UnicodeType"):  # if no unicode support
                    stream.write(fs % msg)
                else:
                    try:
                        stream.write(fs % msg)
                    except UnicodeError:
                        stream.write(fs % msg.encode("UTF-8"))
                self.flush()
            except (__HOLE__, SystemExit):
                raise
            except:
                self.handleError(record)
dataset/ETHPy150Open Pylons/pylons/pylons/log.py/WSGIErrorsHandler.emit