Debug printing refactor in batch mode 86/203286/3
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Thu, 11 Apr 2019 08:36:59 +0000 (10:36 +0200)
committerRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Thu, 16 May 2019 09:30:43 +0000 (11:30 +0200)
Change-Id: Ia957ccf5f7554b79cf5a88819cf981d001544cb0

src/ScanningProperties.cpp
src/batch/BatchRunner.cpp
src/batch/Evaluator.cpp
src/batch/Evaluator.hpp

index 331f6b2..b1e3ada 100644 (file)
@@ -223,4 +223,4 @@ void ScanningProperties::setCachedColor(int value)
 {
        color = Color::fromABGR(value);
        DEBUG("color: %#010x", color.toRGBAInt());
-}
\ No newline at end of file
+}
index e74ee1b..02b7453 100644 (file)
@@ -612,9 +612,12 @@ public:
        WaitGui(BatchExecutor *executor, std::chrono::milliseconds timeout, std::string name)
                : PredicateWaitInterface(executor, timeout)
        {
-               if (name.empty()) {
+               {
                        auto h = self->contextInfo.lock();
-                       this->name = h->rootName;
+                       this->currentContextName = h->rootName;
+               }
+               if (name.empty()) {
+                       this->name = this->currentContextName;
                        searchForAnyChange = true;
                } else {
                        this->name = std::move(name);
@@ -626,6 +629,10 @@ private:
        {
                auto h = self->contextInfo.lock();
                auto pred = [&]() {
+                       if (currentContextName != h->rootName) {
+                               self->outputStream() << "context name changed from '" << currentContextName << "', to '" << h->rootName << "'\n";
+                               currentContextName = h->rootName;
+                       }
                        return (searchForAnyChange && name != h->rootName) || (!searchForAnyChange && name == h->rootName);
                };
                if (pred()) return true;
@@ -640,7 +647,7 @@ private:
                return res;
        }
 
-       std::string name;
+       std::string name, currentContextName;
        bool searchForAnyChange = false;
 };
 
index 2c037fb..0221f7a 100644 (file)
@@ -61,6 +61,11 @@ struct EvaluationDepthCountManager {
        }
 };
 
+DebugEvaluatorInterface *DebugEvaluatorInterface::getCurrentInterface()
+{
+       return debugInterface.get();
+}
+
 void DebugEvaluatorInterface::setCurrentInterface(std::unique_ptr<DebugEvaluatorInterface> inf)
 {
        debugInterface = std::move(inf);
index 2bdf098..99a6257 100644 (file)
@@ -44,6 +44,25 @@ struct DebugEvaluatorInterface {
         * set debug interface before launching any batch execution
         */
        static void setCurrentInterface(std::unique_ptr<DebugEvaluatorInterface> inf = {});
+       static DebugEvaluatorInterface *getCurrentInterface();
+};
+
+class DebugEvaluator
+{
+       std::ostringstream tmp;
+public:
+       DebugEvaluator() = default;
+       ~DebugEvaluator()
+       {
+               auto v = DebugEvaluatorInterface::getCurrentInterface();
+               if (v) v->write(tmp.str());
+       }
+
+       template <typename T> DebugEvaluator &operator << (T &&t)
+       {
+               tmp << std::forward<T>(t);
+               return *this;
+       }
 };
 
 /**