X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftracer.h;h=b01f652f800213d15b7b72478ee2e96fb883512d;hb=15271fce0705ea5611647b5b3d1e993362ff5284;hp=1e2ced161e492305a1655de3ce3c8de5436192b5;hpb=797d87b4513088a66b17c7ac653b84e36ea80458;p=lyx.git diff --git a/src/tracer.h b/src/tracer.h index 1e2ced161e..b01f652f80 100644 --- a/src/tracer.h +++ b/src/tracer.h @@ -20,20 +20,20 @@ #include "LString.h" /// -class DebugTracer { +class Trace { public: /// explicit - DebugTracer(string const & s) : str(s) { - lyxerr << string(depth, ' ') << "Trace begin : " + Trace(string const & s) : str(s) { + lyxerr << string(depth, ' ') << "TRACE IN: " << str << std::endl; - ++depth; + depth += 2; } /// - ~DebugTracer() { - --depth; - lyxerr << string(depth, ' ') << "Trace end : " + ~Trace() { + depth -= 2; + lyxerr << string(depth, ' ') << "TRACE OUT: " << str << std::endl; } private: @@ -43,4 +43,11 @@ private: static int depth; }; +// To avoid wrong usage: +// Trace("BufferView::update"); // wrong +// Trace t("BufferView::update"); // right +// we add this macro: +/// +#define Trace(x) unnamed_Trace; +// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal #endif