23 lines
574 B
C++
23 lines
574 B
C++
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
namespace {
|
|
struct FunctionTracer {
|
|
std::string name;
|
|
inline static int tab_counter = 0;
|
|
|
|
FunctionTracer(const std::string& func): name(func) {
|
|
std::cout << std::string(tab_counter++, '\t') << "BEGIN " << name
|
|
<< std::endl;
|
|
}
|
|
|
|
~FunctionTracer() {
|
|
std::cout << std::string(--tab_counter, '\t') << "Exiting " << name
|
|
<< std::endl;
|
|
}
|
|
};
|
|
} // namespace
|
|
|
|
#define TRACE_FUNCTION FunctionTracer tracer(__FUNCTION__);
|