]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Add PRINT macro to temporarily print a value of an expression
authorMichal Sojka <michal.sojka@cvut.cz>
Wed, 26 Sep 2018 21:39:10 +0000 (23:39 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 27 Sep 2018 05:33:18 +0000 (07:33 +0200)
src/debug.h

index c9a3b94e3c449877bfbcb9007e53e67ef223d1c4..25e39437b607da8e33fa6ab9cf0e44063c94d159 100644 (file)
@@ -71,10 +71,10 @@ class DbgTracer {
     };
 
     template <typename T>
-    void traceVal(const char *name, const T& obj, int line)
+    void traceVal(const char *name, const T& obj, int line, bool always = false)
     {
         (void)line;
-        if (debug)
+        if (debug || always)
             std::cerr << indent() << name /*<< " @" << line */ << " " << print(obj) << std::endl;
     }
 
@@ -127,5 +127,6 @@ extern DbgTracer __dbgTracer;
 
 #define DEBUG_PRINT(obj) __dbgTracer.traceVal(#obj, (obj), __LINE__)
 #define DEBUG_PRINTM(obj) DEBUG_PRINT(obj)
+#define PRINT(obj) __dbgTracer.traceVal(#obj, (obj), __LINE__, true)
 
 #endif // DEBUG_H