Beispiel #1
0
    def exception(self, *args, **kwargs):
        if not self.errors:
            return

        s = StringIO()

        if len(args) == 3:
            type, value, traceback = args
            handler = kwargs.get("handler", None)
            if handler is None:
                handler = "'Unknown'"
            else:
                handler = reprhandler(handler)
            s.write("ERROR in %s (%s): %s\n" % (handler, type, value))
            s.write("%s\n" % "".join(format_tb(traceback)))
        else:
            s.write("Unknown Error\n")
            s.write("args:   %s\n" % repr(args))
            s.write("kwargs: %s\n" % repr(kwargs))

        s.seek(0)

        if self.logger is not None:
            for line in s:
                self.logger.error(line)
        else:
            self.file.write(s.read())
            self.file.flush()

        s.close()
Beispiel #2
0
    def exception(self, type, value, traceback, handler=None):
        if not self.errors:
            return

        s = StringIO()

        if handler is None:
            handler = ""
        else:
            handler = reprhandler(self.root, handler)

        s.write("ERROR %s(%s): %s\n" % ("%s " % handler, type, value))
        s.write("%s\n" % "".join(traceback))

        s.seek(0)

        if self.logger is not None:
            self.logger.error(s.getvalue())
        else:
            self.file.write(s.read())
            self.file.flush()

        s.close()