blob: 1ff64c57cc5f56ded6207d0de5dcdfc27219b683 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMReporter.h"
2
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00003#include "SkCommandLineFlags.h"
commit-bot@chromium.org261c6662014-01-02 16:19:53 +00004#include "OverwriteLine.h"
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00005
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +00006DEFINE_bool2(quiet, q, false, "If true, don't print status updates.");
7DEFINE_bool2(verbose, v, false, "If true, print status updates one-per-line.");
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00008
mtklein@google.comd36522d2013-10-16 13:02:15 +00009namespace DM {
10
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000011void Reporter::finish(SkString name) {
12 sk_atomic_inc(&fFinished);
13
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +000014 if (FLAGS_quiet) {
15 return;
16 }
17
mtklein@google.coma7a9f372013-10-18 20:52:44 +000018 SkString status;
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000019 status.printf("%s%d tasks left",
20 FLAGS_verbose ? "\n" : kSkOverwriteLine,
21 this->started() - this->finished());
mtklein@google.coma7a9f372013-10-18 20:52:44 +000022 const int failed = this->failed();
23 if (failed > 0) {
24 status.appendf(", %d failed", failed);
25 }
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000026 status.appendf("\t[%s done]", name.c_str());
mtklein@google.coma7a9f372013-10-18 20:52:44 +000027 SkDebugf(status.c_str());
mtklein@google.comd36522d2013-10-16 13:02:15 +000028}
29
30int32_t Reporter::failed() const {
31 SkAutoMutexAcquire reader(&fMutex);
32 return fFailures.count();
33}
34
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000035void Reporter::fail(SkString msg) {
mtklein@google.comd36522d2013-10-16 13:02:15 +000036 SkAutoMutexAcquire writer(&fMutex);
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000037 fFailures.push_back(msg);
mtklein@google.comd36522d2013-10-16 13:02:15 +000038}
39
40void Reporter::getFailures(SkTArray<SkString>* failures) const {
41 SkAutoMutexAcquire reader(&fMutex);
42 *failures = fFailures;
43}
44
45} // namespace DM