From 0d4176a96012e7df99819c6634b3435927583a7f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 19 Apr 2018 13:54:33 -0700 Subject: [PATCH] modules/console: Add events subcommand accepting filter-JSON argument. --- modules/console.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index 110a28947..f0d4b98c4 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -1508,6 +1508,34 @@ console_cmd__events(opt &out, const string_view &line) return true; } +bool +console_cmd__events__filter(opt &out, const string_view &line) +{ + const params param{line, " ", + { + "start", "event_filter_json" + }}; + + const uint64_t start + { + param.at(0, uint64_t(-1)) + }; + + const m::event_filter filter + { + param.at(1) + }; + + m::events::rfor_each(start, filter, [&out] + (const uint64_t &seq, const m::event &event) + { + out << seq << " " << pretty_oneline(event) << std::endl;; + return true; + }); + + return true; +} + // // event //