14 #ifdef ARILES_TRACE_ENABLE 27 std::string tabulation_;
28 const std::string function_name_;
29 const std::string file_;
30 const int line_number_;
33 std::size_t getDepth(
const bool increment =
true)
35 static std::size_t depth = 0;
36 if (
true == increment)
46 template <
class t_First,
class... t_Args>
47 void outputFirst(t_First &&first, t_Args &&... args)
50 outputFirst(std::forward<t_Args>(args)...);
53 template <
class t_Last>
54 void outputFirst(t_Last &&last)
56 std::cout << last << std::endl;
61 Tracer(
const std::string &function_name,
const std::string &file,
const int line_number)
62 : function_name_(function_name), file_(file), line_number_(line_number)
64 tabulation_.assign(getDepth(
true),
' ');
66 std::cout << tabulation_
67 <<
">>> Entering function: " << function_name_
68 <<
" | File: " << file_
69 <<
" | Line: " << line_number_ << std::endl;
74 std::cout << tabulation_
75 <<
"<<< Leaving function: " << function_name_
76 <<
" | File: " << file_
77 <<
" | Line: " << line_number_ << std::endl;
82 template <
class... t_Args>
83 void output(t_Args &&... args)
85 std::cout << tabulation_;
86 outputFirst(std::forward<t_Args>(args)...);
89 std::string demangle(
const char *name)
const 94 char *demangled_name = abi::__cxa_demangle(name, NULL, &len, &status);
96 if (demangled_name != NULL)
98 const std::string result(demangled_name);
111 # define ARILES_TRACE_FUNCTION \ 112 char trace_path[] = __FILE__; \ 113 ariles::debug::Tracer tracer(__func__, basename(trace_path), __LINE__); 115 # define ARILES_TRACE_ENTRY(entry_name) tracer.output("Processing entry: ", entry_name); 116 # define ARILES_TRACE_TYPE(entry) tracer.output("Type: ", tracer.demangle(typeid(entry).name())); 118 # define ARILES_TRACE_FUNCTION 119 # define ARILES_TRACE_ENTRY(entry_name) 120 # define ARILES_TRACE_TYPE(entry) #define ARILES_VISIBILITY_ATTRIBUTE