diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-18 23:16:06 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-18 23:16:06 +0800 |
commit | af61f19bce04f6a49ab5179656989c819896be16 (patch) | |
tree | e6cb21f388e16d791509e64c3964fbc2cb68b881 /src/include/debug.hpp | |
parent | 1daa57b7cfd4dc609502f28eeaecdad4cb43b3d4 (diff) | |
download | mrust-af61f19bce04f6a49ab5179656989c819896be16.tar.gz |
Debug - Reduce impact of disabled debug.
Diffstat (limited to 'src/include/debug.hpp')
-rw-r--r-- | src/include/debug.hpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/include/debug.hpp b/src/include/debug.hpp index af8dcf10..21de5493 100644 --- a/src/include/debug.hpp +++ b/src/include/debug.hpp @@ -8,13 +8,19 @@ extern int g_debug_indent_level; #ifndef DISABLE_DEBUG -#define INDENT() do { g_debug_indent_level += 1; assert(g_debug_indent_level<300); } while(0) -#define UNINDENT() do { g_debug_indent_level -= 1; } while(0) -#define DEBUG(ss) do{ if(debug_enabled()) { debug_output(g_debug_indent_level, __FUNCTION__) << ss << ::std::endl; } } while(0) +# define INDENT() do { g_debug_indent_level += 1; assert(g_debug_indent_level<300); } while(0) +# define UNINDENT() do { g_debug_indent_level -= 1; } while(0) +# define DEBUG(ss) do{ if(debug_enabled()) { debug_output(g_debug_indent_level, __FUNCTION__) << ss << ::std::endl; } } while(0) +# define TRACE_FUNCTION TraceLog _tf_(__func__) +# define TRACE_FUNCTION_F(ss) TraceLog _tf_(__func__, [&](::std::ostream&__os){ __os << ss; }) +# define TRACE_FUNCTION_FR(ss,ss2) TraceLog _tf_(__func__, [&](::std::ostream&__os){ __os << ss; }, [&](::std::ostream&__os){ __os << ss2;}) #else -#define INDENT() do { } while(0) -#define UNINDENT() do {} while(0) -#define DEBUG(ss) do{ (void)(::NullSink() << ss); } while(0) +# define INDENT() do { } while(0) +# define UNINDENT() do {} while(0) +# define DEBUG(ss) do{ (void)(::NullSink() << ss); } while(0) +# define TRACE_FUNCTION do{} while(0) +# define TRACE_FUNCTION_F(ss) do{ (void)(::NullSink() << ss); } while(0) +# define TRACE_FUNCTION_FR(ss,ss2) do{ (void)(::NullSink() << ss); } while(0) #endif extern bool debug_enabled(); @@ -44,8 +50,8 @@ class TraceLog const char* m_tag; ::std::function<void(::std::ostream&)> m_ret; public: - TraceLog(const char* tag, ::std::string info, ::std::function<void(::std::ostream&)> ret); - TraceLog(const char* tag, ::std::string info); + TraceLog(const char* tag, ::std::function<void(::std::ostream&)> info_cb, ::std::function<void(::std::ostream&)> ret); + TraceLog(const char* tag, ::std::function<void(::std::ostream&)> info_cb); TraceLog(const char* tag); ~TraceLog(); }; @@ -60,8 +66,4 @@ struct FmtLambda }; #define FMT_CB(os, ...) ::FmtLambda { [&](auto& os) { __VA_ARGS__ } } -#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;}) - |