def print_event(self, e): short = e['from'][:8] d = e['d'] when = format_time(d['time'], self.options["timestamps"]) if self.options['just-numbers']: print >> self.options.stdout, when, d.get('num') return eid = (d["incarnation"], d["num"]) # let's mark the trigger event from incident reports with # [INCIDENT-TRIGGER] at the end of the line is_trigger = bool(self.trigger and (eid == self.trigger)) text = format_message(d) t = "%s#%d " % (short, d['num']) if self.options['rx-time']: rx_when = format_time(e['rx_time'], self.options["timestamps"]) t += "rx(%s) " % rx_when t += "emit(%s)" % when else: t += "%s" % when t += ": %s" % text if self.options['verbose']: t += ": %r" % d if is_trigger: t += " [INCIDENT-TRIGGER]" print >> self.options.stdout, t if 'failure' in d: print >> self.options.stdout, " FAILURE:" lines = str(d['failure']).split("\n") for line in lines: print >> self.options.stdout, " %s" % (line, )
def to_html(self, href_base="", timestamps="short-local"): d = self.e['d'] time_short, time_extended = web_format_time(d['time'], timestamps) msg = html.escape(log.format_message(d)) if 'failure' in d: lines = str(d['failure']).split("\n") html_lines = [html.escape(line) for line in lines] f_html = "\n".join(html_lines) msg += " FAILURE:<pre>%s</pre>" % f_html level = d.get('level', log.OPERATIONAL) level_s = "" if level >= log.UNUSUAL: level_s = self.LEVELMAP.get(level, "") + " " details = " ".join(["Event #%d" % d['num'], "TubID=%s" % self.e['from'], "Incarnation=%s" % self.incarnation, time_extended]) label = '<span title="%s">%s</span>' % (details, time_short) data = '%s [<span id="E%s"><a href="%s#E%s">%d</a></span>]: %s%s' \ % (label, self.anchor_index, href_base, self.anchor_index, d['num'], level_s, msg) if self.is_trigger: data += " [INCIDENT-TRIGGER]" return data
def print_event(self, e): short = e['from'][:8] d = e['d'] when = self.format_time(d['time']) if self.options['just-numbers']: print >>self.options.stdout, when, d.get('num') return eid = (d["incarnation"], d["num"]) # let's mark the trigger event from incident reports with # [INCIDENT-TRIGGER] at the end of the line is_trigger = bool(self.trigger and (eid == self.trigger)) text = format_message(d) t = "%s#%d " % (short, d['num']) if self.options['rx-time']: rx_when = self.format_time(e['rx_time']) t += "rx(%s) " % rx_when t += "emit(%s)" % when else: t += "%s" % when t += ": %s" % text if self.options['verbose']: t += ": %r" % d if is_trigger: t += " [INCIDENT-TRIGGER]" print >>self.options.stdout, t if 'failure' in d: print >>self.options.stdout," FAILURE:" lines = str(d['failure']).split("\n") for line in lines: print >>self.options.stdout, " %s" % (line,)
def run(self, options): self.add_classify_files(options["classifier-directory"]) out = options.stdout for f in options.files: abs_fn = os.path.expanduser(f) incident = self.load_incident(abs_fn) categories = self.classify_incident(incident) print("%s: %s" % (f, ",".join(sorted(categories))), file=out) if list(categories) == ["unknown"] and options["verbose"]: (header, events) = incident trigger = header["trigger"] from foolscap.logging.log import format_message print(format_message(trigger), file=out) pprint.pprint(trigger, stream=out) if 'failure' in trigger: print(" FAILURE:", file=out) lines = str(trigger['failure']).split("\n") for line in lines: print(" %s" % (line, ), file=out) print('', file=out)
def formatted_print(self, d): time_s = format_time(d['time'], self.options["timestamps"]) msg = log.format_message(d) level = d.get('level', log.OPERATIONAL) tubid = "" # TODO print("%s L%d [%s]#%d %s" % (time_s, level, tubid, d["num"], msg), file=self.output) if 'failure' in d: print(" FAILURE:", file=self.output) lines = str(d['failure']).split("\n") for line in lines: print(" %s" % (line, ), file=self.output)
def formatted_print(self, d): time_s = format_time(d['time'], self.options["timestamps"]) msg = log.format_message(d) level = d.get('level', log.OPERATIONAL) tubid = "" # TODO print >>self.output, "%s L%d [%s]#%d %s" % (time_s, level, tubid, d["num"], msg) if 'failure' in d: print >>self.output, " FAILURE:" lines = str(d['failure']).split("\n") for line in lines: print >>self.output, " %s" % (line,)
def formatted_print(self, d): time_s = time.strftime("%H:%M:%S", time.localtime(d['time'])) time_s = time_s + ".%03d" % int(1000*(d['time'] - int(d['time']))) msg = log.format_message(d) level = d.get('level', log.OPERATIONAL) tubid = "" # TODO print >>self.output, "%s L%d [%s]#%d %s" % (time_s, level, tubid, d["num"], msg) if 'failure' in d: print >>self.output, " FAILURE:" lines = str(d['failure']).split("\n") for line in lines: print >>self.output, " %s" % (line,)
def formatted_print(self, d): time_s = time.strftime("%H:%M:%S", time.localtime(d['time'])) time_s = time_s + ".%03d" % int(1000 * (d['time'] - int(d['time']))) msg = log.format_message(d) level = d.get('level', log.OPERATIONAL) tubid = "" # TODO print >> self.output, "%s L%d [%s]#%d %s" % (time_s, level, tubid, d["num"], msg) if 'failure' in d: print >> self.output, " FAILURE:" lines = str(d['failure']).split("\n") for line in lines: print >> self.output, " %s" % (line, )
def run(self, options): self.add_classify_files(options["classifier-directory"]) out = options.stdout for f in options.files: abs_fn = os.path.expanduser(f) incident = self.load_incident(abs_fn) categories = self.classify_incident(incident) print >>out, "%s: %s" % (f, ",".join(sorted(categories))) if list(categories) == ["unknown"] and options["verbose"]: (header, events) = incident trigger = header["trigger"] from foolscap.logging.log import format_message print >>out, format_message(trigger) pprint(trigger, stream=out) if 'failure' in trigger: print >>out," FAILURE:" lines = str(trigger['failure']).split("\n") for line in lines: print >>out, " %s" % (line,) print >>out, ""
def print_event(self, e, options): stdout = options.stdout short = e['from'][:8] d = e['d'] when = format_time(d['time'], options["timestamps"]) if options['just-numbers']: print(six.text_type(when), six.text_type(d.get('num')), file=stdout) return eid = (d["incarnation"], d["num"]) # let's mark the trigger event from incident reports with # [INCIDENT-TRIGGER] at the end of the line is_trigger = bool(self.trigger and (eid == self.trigger)) try: text = format_message(d) except: print(u"unformattable event", d) raise t = "%s#%d " % (short, d['num']) if options['rx-time']: rx_when = format_time(e['rx_time'], options["timestamps"]) t += "rx(%s) " % rx_when t += "emit(%s)" % when else: t += "%s" % when t += ": %s" % text if options['verbose']: t += ": %r" % d if is_trigger: t += " [INCIDENT-TRIGGER]" print(t, file=stdout) if 'failure' in d: print(u" FAILURE:", file=stdout) lines = str(d['failure'].get('str', d['failure'])).split("\n") for line in lines: print(u" %s" % (line, ), file=stdout)