Added LOG_LEVEL_SCOPE() which sets the log level and resets it to the previous value once it goes out of scope. Couldn't remember what I needed this for when I was done writing it, but maybe someone will find a use for it...

This commit is contained in:
2015-12-29 22:42:58 +01:00
parent b5605c839d
commit c5b4ea84a0
+23
View File
@@ -80,4 +80,27 @@ static void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsign
#define LOG_DEBUG(format, ...) \
LOG(LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
// Set the log level temporarily for the current scope
#define LOG_LEVEL_SCOPE(logLevel) \
_LOG_LEVEL_SCOPED_HELPER<logLevel> _logLevelScopedHelper;
template <_LOG_LEVEL LEVEL>
class _LOG_LEVEL_SCOPED_HELPER
{
public:
_LOG_LEVEL_SCOPED_HELPER()
{
m_OriginalLogLevel = LOG_LEVEL;
LOG_LEVEL = LEVEL;
}
~_LOG_LEVEL_SCOPED_HELPER()
{
LOG_LEVEL = m_OriginalLogLevel;
}
private:
_LOG_LEVEL m_OriginalLogLevel;
};
#endif // Logging_h__