diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Utilities/LogUtility.h |
Diffstat (limited to 'Runtime/Utilities/LogUtility.h')
-rw-r--r-- | Runtime/Utilities/LogUtility.h | 28 |
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 |