def emit(self, record):
        msg = self.format(record)
        try:
            self.stream.write(msg)
        except (UnicodeError, __HOLE__):
            try:
                self.stream.write(msg.encode("utf8"))
            except (UnicodeError, TypeError):
                try:
                    self.stream.write(msg.encode("utf8").decode('ascii', 'replace'))
                except (UnicodeError, TypeError):
                    self.stream.write(repr(msg))
        self.stream.write(os.linesep)
        try:
            self.flush()
        except OSError as e:
            if e.args[0] == 28:
                print('No space left on device, cannot flush log.')
            else:
                raise
dataset/ETHPy150Open ProgVal/Limnoria/src/log.py/BetterFileHandler.emit