How to use the foolscap.util.format_time function in foolscap

To help you get started, we’ve selected a few foolscap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github warner / foolscap / foolscap / logging / dumper.py View on Github external
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))
        try:
            text = format_message(d)
        except:
            print "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 >>stdout, t
        if 'failure' in d:
            print >>stdout," FAILURE:"
            lines = str(d['failure']).split("\n")
            for line in lines:
                print >>stdout, " %s" % (line,)
github warner / foolscap / src / foolscap / logging / tail.py View on Github external
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)
github warner / foolscap / foolscap / logging / dumper.py View on Github external
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))
        try:
            text = format_message(d)
        except:
            print "unformattable event", d
            raise

        t = "%s#%d " % (short, d['num'])
        if options['rx-time']:
github warner / foolscap / src / foolscap / logging / web.py View on Github external
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
github warner / foolscap / src / foolscap / logging / web.py View on Github external
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
github warner / foolscap / src / foolscap / logging / web.py View on Github external
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