From: Jason Dillaman Date: Wed, 7 Oct 2015 19:39:18 +0000 (-0400) Subject: rbd-replay-prep: added --verbose command line option X-Git-Tag: v0.94.6~69^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a30ed76c34ecca6278112908871126e1730a22bc;p=ceph.git 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 (cherry picked from commit 646e50a771c3089121ec2f4369d1a8188001a3eb) --- diff --git a/doc/man/8/rbd-replay-prep.rst b/doc/man/8/rbd-replay-prep.rst index 3d4ce8548676..64e636caefe8 100644 --- a/doc/man/8/rbd-replay-prep.rst +++ b/doc/man/8/rbd-replay-prep.rst @@ -27,6 +27,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 80a572cdc166..94042a5191ee 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) {