summaryrefslogtreecommitdiff
path: root/src/include/debug.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/debug.hpp')
-rw-r--r--src/include/debug.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/include/debug.hpp b/src/include/debug.hpp
index 7e68bbfa..af8dcf10 100644
--- a/src/include/debug.hpp
+++ b/src/include/debug.hpp
@@ -49,6 +49,17 @@ public:
TraceLog(const char* tag);
~TraceLog();
};
+
+struct FmtLambda
+{
+ ::std::function<void(::std::ostream&)> m_cb;
+ friend ::std::ostream& operator<<(::std::ostream& os, const FmtLambda& x) {
+ x.m_cb(os);
+ return os;
+ }
+};
+#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;})