A more exotic solution could be to have a look a Aspect-Oriented Programming. One fundamental example is to log function call.
See this for C++ examples.
Edit : a small example from AspectC++ to trace a call from a member function (Iter::Reset in that case)
aspect Tracer
{
advice call("% %Iter::Reset(...)") : before()
{
cerr << "about to call Iter::Reset for " << JoinPoint::signature() << endl;
}
};