I'm planning to add extensive diagnostics into my software. Right now I'm thinking about overall strategy of how to do this, because adding such code simply ad hoc can result in serious mess.
Do you have any experience in this?
I want to monitor:
- How intensively objects from selected subset are created.
- How intensively selected methods are called.
- Number of other events in selected periods of time.
- For selected methods gather information about callers (libcwd allows this?)
- Amount of time consumed by each thread in sequence of time periods.
My software is a processing-like tool, which in general works like other processing or computing tools, like lame mp3 encoder for example. This is why such overall statistics harvesting does have sense for me.
I'm currently planning to add a base class for each object that I want to monitor for creations/destructions. The base class would log proper information in its constructors and destructors. What else can be done??
class LifeCycleProbe {
char * name;
LifeCycleProbe(char * _name) : name(_name) {
some::important::object.created(_name);
}
~LifeCycleProbe() {
some::important::object.destroyed(_name);
}
}
class MonitorMe : private LifeCycleProbe {
MonitorMe() : LifeCycleProbe("MonitorMe") {
// ...
}
}