November 1999
Intermediate to advanced
336 pages
6h 29m
English
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) ...
Read now
Unlock full access