Пример #1
0
    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, )
Пример #2
0
 def test_format(self):
     when = 1339286175.7071271
     self.failUnlessEqual(util.format_time(when, "utc"),
                          "2012-06-09_23:56:15.707127Z")
     self.failUnlessEqual(util.format_time(when, "epoch"), "1339286175.707")
     self.failUnless(":" in util.format_time(when, "short-local"))
     self.failUnless(":" in util.format_time(when, "long-local"))
Пример #3
0
def web_format_time(t, mode="short-local"):
    time_s = format_time(t, mode)
    time_utc = format_time(t, "utc")
    time_local = format_time(t, "long-local")
    time_ctime = time.ctime(t).replace(" ", " ")
    extended = "Local=%s  Local=%s  UTC=%s" % (time_ctime, time_local, time_utc)
    return time_s, extended
Пример #4
0
def web_format_time(t, mode="short-local"):
    time_s = format_time(t, mode)
    time_utc = format_time(t, "utc")
    time_local = format_time(t, "long-local")
    time_ctime = time.ctime(t).replace(" ", " ")
    extended = "Local=%s  Local=%s  UTC=%s" % (time_ctime, time_local, time_utc)
    return time_s, extended
Пример #5
0
    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 >>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 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 >>stdout, t
        if 'failure' in d:
            print >>stdout," FAILURE:"
            lines = str(d['failure']).split("\n")
            for line in lines:
                print >>stdout, " %s" % (line,)
Пример #6
0
 def test_format(self):
     when = 1339286175.7071271
     self.failUnlessEqual(util.format_time(when, "utc"),
                          "2012-06-09_23:56:15.707127Z")
     self.failUnlessEqual(util.format_time(when, "epoch"),
                          "1339286175.707")
     self.failUnless(":" in util.format_time(when, "short-local"))
     self.failUnless(":" in util.format_time(when, "long-local"))
Пример #7
0
    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)
Пример #8
0
    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)
Пример #9
0
    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,)