summaryrefslogtreecommitdiff
path: root/src/debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug.cpp')
-rw-r--r--src/debug.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/debug.cpp b/src/debug.cpp
new file mode 100644
index 00000000..a09fc648
--- /dev/null
+++ b/src/debug.cpp
@@ -0,0 +1,42 @@
+
+#include <debug.hpp>
+
+TraceLog::TraceLog(const char* tag, ::std::string info, ::std::function<void(::std::ostream&)> ret):
+ m_tag(tag),
+ m_ret(ret)
+{
+ if(debug_enabled()) {
+ auto& os = debug_output(g_debug_indent_level, m_tag);
+ os << ">> (" << info << ")" << ::std::endl;
+ }
+ INDENT();
+}
+TraceLog::TraceLog(const char* tag, ::std::string info):
+ m_tag(tag),
+ m_ret([](const auto&){})
+{
+ if(debug_enabled()) {
+ auto& os = debug_output(g_debug_indent_level, m_tag);
+ os << ">> (" << info << ")" << ::std::endl;
+ }
+ INDENT();
+}
+TraceLog::TraceLog(const char* tag):
+ m_tag(tag),
+ m_ret([](const auto&){})
+{
+ if(debug_enabled()) {
+ auto& os = debug_output(g_debug_indent_level, m_tag);
+ os << ">>" << ::std::endl;
+ }
+ INDENT();
+}
+TraceLog::~TraceLog() {
+ UNINDENT();
+ if(debug_enabled()) {
+ auto& os = debug_output(g_debug_indent_level, m_tag);
+ os << "<< (";
+ m_ret(os);
+ os << ")" << ::std::endl;
+ }
+}