added a way to show the call stack of the functions
This commit is contained in:
22
src/utils/tracer.hpp
Normal file
22
src/utils/tracer.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#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__);
|
Reference in New Issue
Block a user