summaryrefslogtreecommitdiff
path: root/Runtime/Utilities/LogUtility.h
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Utilities/LogUtility.h')
-rw-r--r--Runtime/Utilities/LogUtility.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/Runtime/Utilities/LogUtility.h b/Runtime/Utilities/LogUtility.h
new file mode 100644
index 0000000..164ea3f
--- /dev/null
+++ b/Runtime/Utilities/LogUtility.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "LogAssert.h"
+
+// Nested log with automatic indentation. NESTED_LOG(name,fmt,...) prints to the console
+// and indents further log calls. Log indentation is decreased again when current scope ends.
+
+class NestedLogOutput
+{
+public:
+ NestedLogOutput(const char* name, const std::string& msg)
+ {
+ printf_console("%s: %*c%s\n", name, s_LogDepth, ' ', msg.c_str());
+ s_LogDepth += 4;
+ }
+ ~NestedLogOutput()
+ {
+ s_LogDepth -= 4;
+ }
+private:
+ static int s_LogDepth;
+};
+
+#if !UNITY_RELEASE
+#define NESTED_LOG(name,...) NestedLogOutput _nested_log_##__LINE__ (name,Format(__VA_ARGS__))
+#else
+#define NESTED_LOG(name,...)
+#endif