From a8470b82f1f9b3b40b98e9c813bdc4d71361c001 Mon Sep 17 00:00:00 2001 From: Nandana Dutt Date: Mon, 11 Mar 2019 11:00:58 +0000 Subject: Log duration to logcat always. Remove TODO and make the logging behavior intentional. Rename field to make the intent clearer. BUG:128270426 Test: took bugreport and verified log lines: adb logcat | grep "Duration was" Change-Id: I6a9379af9ee6a03587c40c35f3f242d84ddf3bc3 --- cmds/dumpstate/dumpstate.h | 4 ++-- cmds/dumpstate/utils.cpp | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index c326bb6bfa..96aacd41d9 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -73,13 +73,13 @@ extern "C" { */ class DurationReporter { public: - explicit DurationReporter(const std::string& title, bool log_only = false); + explicit DurationReporter(const std::string& title, bool logcat_only = false); ~DurationReporter(); private: std::string title_; - bool log_only_; + bool logcat_only_; uint64_t started_; DISALLOW_COPY_AND_ASSIGN(DurationReporter); diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp index 2a5516d7f5..7e641aa708 100644 --- a/cmds/dumpstate/utils.cpp +++ b/cmds/dumpstate/utils.cpp @@ -95,8 +95,8 @@ Dumpstate& Dumpstate::GetInstance() { return singleton_; } -DurationReporter::DurationReporter(const std::string& title, bool log_only) - : title_(title), log_only_(log_only) { +DurationReporter::DurationReporter(const std::string& title, bool logcat_only) + : title_(title), logcat_only_(logcat_only) { if (!title_.empty()) { started_ = Nanotime(); } @@ -105,15 +105,13 @@ DurationReporter::DurationReporter(const std::string& title, bool log_only) DurationReporter::~DurationReporter() { if (!title_.empty()) { uint64_t elapsed = Nanotime() - started_; - if (log_only_) { - MYLOGD("Duration of '%s': %.3fs\n", title_.c_str(), (float)elapsed / NANOS_PER_SEC); - } else { - // TODO(124089395): Remove or rewrite when bugreport latency is fixed. - MYLOGD("Duration of '%s': %.3fs\n", title_.c_str(), (float)elapsed / NANOS_PER_SEC); - // Use "Yoda grammar" to make it easier to grep|sort sections. - printf("------ %.3fs was the duration of '%s' ------\n", (float)elapsed / NANOS_PER_SEC, - title_.c_str()); + MYLOGD("Duration of '%s': %.3fs\n", title_.c_str(), (float)elapsed / NANOS_PER_SEC); + if (logcat_only_) { + return; } + // Use "Yoda grammar" to make it easier to grep|sort sections. + printf("------ %.3fs was the duration of '%s' ------\n", (float)elapsed / NANOS_PER_SEC, + title_.c_str()); } } -- cgit v1.2.3-59-g8ed1b