From 646e50a771c3089121ec2f4369d1a8188001a3eb Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 7 Oct 2015 15:39:18 -0400 Subject: [PATCH] rbd-replay-prep: added --verbose command line option This new command-line will dump all the processed events as they are extracted from the trace file. Signed-off-by: Jason Dillaman --- doc/man/8/rbd-replay-prep.rst | 3 +++ src/rbd_replay/rbd-replay-prep.cc | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/man/8/rbd-replay-prep.rst b/doc/man/8/rbd-replay-prep.rst index 4b78ac3fcdbc0..abb08decf11c2 100644 --- a/doc/man/8/rbd-replay-prep.rst +++ b/doc/man/8/rbd-replay-prep.rst @@ -29,6 +29,9 @@ Options Anonymizes image and snap names. +.. option:: --verbose + + Print all processed events to console Examples ======== diff --git a/src/rbd_replay/rbd-replay-prep.cc b/src/rbd_replay/rbd-replay-prep.cc index 80a572cdc1661..94042a5191eec 100644 --- a/src/rbd_replay/rbd-replay-prep.cc +++ b/src/rbd_replay/rbd-replay-prep.cc @@ -115,7 +115,10 @@ private: }; static void usage(string prog) { - cout << "Usage: " << prog << " [ --window ] [ --anonymize ] " << endl; + std::stringstream str; + str << "Usage: " << prog << " "; + std::cout << str.str() << "[ --window ] [ --anonymize ] [ --verbose ]" << std::endl + << std::string(str.str().size(), ' ') << " " << endl; } __attribute__((noreturn)) static void usage_exit(string prog, string msg) { @@ -129,7 +132,8 @@ public: Processor() : m_window(1000000000ULL), // 1 billion nanoseconds, i.e., one second m_io_count(0), - m_anonymize(false) { + m_anonymize(false), + m_verbose(false) { } void run(vector args) { @@ -148,6 +152,8 @@ public: m_window = (uint64_t)(1e9 * atof(arg.c_str() + sizeof("--window="))); } else if (arg == "--anonymize") { m_anonymize = true; + } else if (arg == "--verbose") { + m_verbose = true; } else if (arg == "-h" || arg == "--help") { usage(args[0]); exit(0); @@ -228,7 +234,13 @@ public: private: void serialize_events(Ser &ser, const IO::ptrs &ptrs) { for (IO::ptrs::const_iterator it = ptrs.begin(); it != ptrs.end(); ++it) { - (*it)->write_to(ser); + IO::ptr io(*it); + io->write_to(ser); + + if (m_verbose) { + io->write_debug(std::cout); + std::cout << std::endl; + } } } @@ -415,8 +427,6 @@ private: completed(completedIO); } } - - // cout << ts << "\t" << event_name << "\tthreadID = " << threadID << endl; } action_id_t next_id() { @@ -487,6 +497,8 @@ private: bool m_anonymize; map m_anonymized_images; + + bool m_verbose; }; int main(int argc, char** argv) { -- 2.39.5