def log_queue(log_to=None): if log_to: # standard logfile jlog = munk.file_sink(log_to+".log") jlog = munk.jsonify(jlog) jlog = munk.timify(jlog, tag="timestamp") jlog = munk.exclude(jlog, "params") # parameter logfile paraml = munk.file_sink(log_to+".params") paraml = munk.jsonify(paraml) paraml = munk.timify(paraml, tag="timestamp") paraml = munk.include(paraml, "params") jplog = munk.broadcast(*[jlog, paraml]) # finally a pretty printer for some immediate feedback pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") pp = munk.include_tags_only(pp, "pretty") jplog = munk.exclude_tags(jplog, "pretty") log = munk.broadcast(*[jplog, pp]) else: pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") log = munk.include_tags_only(pp, "pretty") return log
def log_queue(log_to=None): if log_to: # standard logfile jlog = munk.file_sink(log_to + ".log") jlog = munk.jsonify(jlog) jlog = munk.timify(jlog, tag="timestamp") jlog = munk.exclude(jlog, "params") # parameter logfile paraml = munk.file_sink(log_to + ".params") paraml = munk.jsonify(paraml) paraml = munk.timify(paraml, tag="timestamp") paraml = munk.include(paraml, "params") jplog = munk.broadcast(*[jlog, paraml]) # finally a pretty printer for some immediate feedback pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") pp = munk.include_tags_only(pp, "pretty") jplog = munk.exclude_tags(jplog, "pretty") log = munk.broadcast(*[jplog, pp]) else: pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") log = munk.include_tags_only(pp, "pretty") return log
def test_timing(): lst = [] pipe = L.list_sink(lst) pipe = L.timify(pipe) pipe.send({}) assert len(lst) == 1, 'nothing added to sink' assert 'datetime' in lst[0]