From 368c42ce7e5355341d547e5af6b71808dfd01acb Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 8 Jun 2016 10:02:13 +0800 Subject: Resolve - Fix generic binding indexes --- src/include/debug.hpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/debug.hpp b/src/include/debug.hpp index 9dafdb42..2b3b1bee 100644 --- a/src/include/debug.hpp +++ b/src/include/debug.hpp @@ -3,6 +3,7 @@ #pragma once #include #include +#include extern int g_debug_indent_level; @@ -41,21 +42,42 @@ public: class TraceLog { const char* m_tag; + ::std::function m_ret; public: - TraceLog(const char* tag, ::std::string info): m_tag(tag) { + TraceLog(const char* tag, ::std::string info, ::std::function ret): + m_tag(tag), + m_ret(ret) + { DEBUG(" >> " << m_tag << "(" << info << ")"); INDENT(); } - TraceLog(const char* tag): m_tag(tag) { + TraceLog(const char* tag, ::std::string info): + m_tag(tag), + m_ret([](const auto&){}) + { + DEBUG(" >> " << m_tag << "(" << info << ")"); + INDENT(); + } + TraceLog(const char* tag): + m_tag(tag), + m_ret([](const auto&){}) + { DEBUG(" >> " << m_tag); INDENT(); } ~TraceLog() { UNINDENT(); DEBUG("<< " << m_tag); + if(debug_enabled()) { + auto& os = debug_output(g_debug_indent_level, __FUNCTION__); + os << "<<" << m_tag; + m_ret(os); + os << ::std::endl; + } } }; #define TRACE_FUNCTION TraceLog _tf_(__func__) #define TRACE_FUNCTION_F(ss) TraceLog _tf_(__func__, FMT(ss)) +#define TRACE_FUNCTION_FR(ss,ss2) TraceLog _tf_(__func__, FMT(ss), [&](::std::ostream&__os){ __os<<"(" << ss2 <<"}";}) -- cgit v1.2.3