blob: 31310d1cd9a70cbf7610ed03ae7fa91c454182d8 [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"
4
5DEFINE_bool(quiet, false, "If true, don't print status updates.");
6
mtklein@google.comd36522d2013-10-16 13:02:15 +00007namespace DM {
8
9void Reporter::updateStatusLine() const {
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +000010 if (FLAGS_quiet) {
11 return;
12 }
13
mtklein@google.coma7a9f372013-10-18 20:52:44 +000014 SkString status;
rmistry@google.comd6bab022013-12-02 13:50:38 +000015 status.printf("\r\033[K%d tasks left", this->started() - this->finished());
mtklein@google.coma7a9f372013-10-18 20:52:44 +000016 const int failed = this->failed();
17 if (failed > 0) {
18 status.appendf(", %d failed", failed);
19 }
20 SkDebugf(status.c_str());
mtklein@google.comd36522d2013-10-16 13:02:15 +000021}
22
23int32_t Reporter::failed() const {
24 SkAutoMutexAcquire reader(&fMutex);
25 return fFailures.count();
26}
27
28void Reporter::fail(SkString name) {
29 SkAutoMutexAcquire writer(&fMutex);
30 fFailures.push_back(name);
31}
32
33void Reporter::getFailures(SkTArray<SkString>* failures) const {
34 SkAutoMutexAcquire reader(&fMutex);
35 *failures = fFailures;
36}
37
38} // namespace DM