Our Initial Trace Implementation
Our intent was to have the trace object log event messages such as entering a function, leaving a function, and possibly other information of interest between those two events.
int myFunction(int x) { string name = "myFunction"; Trace t(name); ... string moreInfo = "more interesting info"; t.debug(moreInfo); ... }; // Trace destructor logs exit event to an output stream
To enable this usage we started out with the following Trace implementation:
class Trace { public: Trace (const string &name); ~Trace (); void debug (const string &msg); static bool traceIsActive; private: string theFunctionName; };
The Trace constructor stores the function's name.
inline Trace::Trace(const string &name) : theFunctionName(name) ...
Get Efficient C++ Performance Programming Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.