def report_(err, verbose=False): """A report wrapper which reports backtraces for exceptions""" if hasattr(err,"report"): for r in err.report(): yield r elif not isinstance(err,BaseException): yield unicode(err) elif verbose and not getattr(err,"no_backtrace",False): from traceback import format_stack p = "ERROR: " for l in format_exception(err).rstrip("\n").split("\n"): yield p+l p=" : " if hasattr(err,"cmd"): yield " at: "+cmd.file+":"+unicode(cmd.line) if hasattr(err,"within"): for w in err.within: p = " in: " for r in w.report(verbose): yield p+r p = " : " if track_errors(): p = " by: " for rr in format_stack(): for r in rr.rstrip("\n").split("\n"): yield p+r p = " : " else: yield "ERROR: "+unicode(err)
def log_event(self, event, level=0): # if level < self.level: # return if TESTING and int(os.environ["HOMEVENT_TEST"]) > 1: self._log(None,"@ "+ixtime()) if hasattr(event,"report"): for r in event.report(99): self._log(None,unicode(r)) elif isinstance(event,BaseException): for l in format_exception(event).strip('\n').split('\n'): self._log(None,l) else: self._log(None,unicode(event)) if self.dot: self._log(None,".")