def main(): for line in io.lines(sys.stdin): msg = json.loads(line) if '@timestamp' in msg: print(msg['@timestamp'], msg['@message']) else: print(msg['@message'])
def main(): args = parser.parse_args() filterlist = [args.filters] if args.filters_append: filterlist.extend(args.filters_append) pipeline = filters.build(','.join(filterlist)) for msg in pipeline(io.lines(sys.stdin)): print(json.dumps(msg))
def test_lines(): _, fname = tempfile.mkstemp() register_cleanup(fname) with open(fname, 'w') as f: f.writelines(['foo\n', 'bar\n', 'baz\n']) with open(fname) as f: res = io.lines(f) assert_equal(next(res), 'foo\n') assert_equal(next(res), 'bar\n') assert_equal(next(res), 'baz\n')
def test_lines(): _, fname = tempfile.mkstemp() register_cleanup(fname) with open(fname, "w") as f: f.writelines(["foo\n", "bar\n", "baz\n"]) with open(fname) as f: res = io.lines(f) assert_equal(next(res), "foo\n") assert_equal(next(res), "bar\n") assert_equal(next(res), "baz\n")
def main(): args = parser.parse_args() shippers = [] for shipper_desc in args.shipper: shippers.append(build_shipper(shipper_desc)) filterlist = [args.filters] if args.filters_append: filterlist.extend(args.filters_append) pipeline = filters.build(','.join(filterlist)) for msg in pipeline(io.lines(sys.stdin)): for shpr in shippers: shpr.ship(msg)
def main(): for msg in io.lines(sys.stdin): print(now(), msg, end='')