Skip to content
Snippets Groups Projects
Commit b5f5f391 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Nop out debug logging in release builds

parent d6bc9fef
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,7 @@ const int LL_ERR_NOERR = 0; ...@@ -44,6 +44,7 @@ const int LL_ERR_NOERR = 0;
#define RELEASE_SHOW_WARN // Define this if you want your release builds to show llwarn output. #define RELEASE_SHOW_WARN // Define this if you want your release builds to show llwarn output.
#ifdef _DEBUG #ifdef _DEBUG
#define ENABLE_DEBUG 1
#define SHOW_DEBUG #define SHOW_DEBUG
#define SHOW_WARN #define SHOW_WARN
#define SHOW_INFO #define SHOW_INFO
...@@ -51,10 +52,12 @@ const int LL_ERR_NOERR = 0; ...@@ -51,10 +52,12 @@ const int LL_ERR_NOERR = 0;
#else // _DEBUG #else // _DEBUG
#ifdef LL_RELEASE_WITH_DEBUG_INFO #ifdef LL_RELEASE_WITH_DEBUG_INFO
#define ENABLE_DEBUG 1
#define SHOW_ASSERT #define SHOW_ASSERT
#endif // LL_RELEASE_WITH_DEBUG_INFO #endif // LL_RELEASE_WITH_DEBUG_INFO
#ifdef RELEASE_SHOW_DEBUG #ifdef RELEASE_SHOW_DEBUG
#define ENABLE_DEBUG 1
#define SHOW_DEBUG #define SHOW_DEBUG
#endif #endif
...@@ -289,6 +292,7 @@ namespace LLError ...@@ -289,6 +292,7 @@ namespace LLError
} }
//this is cheaper than llcallstacks if no need to output other variables to call stacks. //this is cheaper than llcallstacks if no need to output other variables to call stacks.
#if ENABLE_DEBUG
#define LL_PUSH_CALLSTACKS() LLError::LLCallStacks::push(__FUNCTION__, __LINE__) #define LL_PUSH_CALLSTACKS() LLError::LLCallStacks::push(__FUNCTION__, __LINE__)
#define llcallstacks \ #define llcallstacks \
...@@ -300,6 +304,20 @@ namespace LLError ...@@ -300,6 +304,20 @@ namespace LLError
LLError::End(); \ LLError::End(); \
LLError::LLCallStacks::end(_out) ; \ LLError::LLCallStacks::end(_out) ; \
} }
#else
#define LL_PUSH_CALLSTACKS()
#define llcallstacks \
if (false) \
{ \
std::ostringstream* _out = LLError::LLCallStacks::insert(__FUNCTION__, __LINE__) ; \
(*_out)
#define llcallstacksendl \
LLError::End(); \
LLError::LLCallStacks::end(_out) ; \
}
#endif
#define LL_CLEAR_CALLSTACKS() LLError::LLCallStacks::clear() #define LL_CLEAR_CALLSTACKS() LLError::LLCallStacks::clear()
#define LL_PRINT_CALLSTACKS() LLError::LLCallStacks::print() #define LL_PRINT_CALLSTACKS() LLError::LLCallStacks::print()
...@@ -346,6 +364,30 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; ...@@ -346,6 +364,30 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
std::ostringstream* _out = LLError::Log::out(); \ std::ostringstream* _out = LLError::Log::out(); \
(*_out) (*_out)
#ifdef ENABLE_DEBUG
#define lllog_debug(level, once, ...) \
do { \
const char* tags[] = {"", ##__VA_ARGS__}; \
static LLError::CallSite _site(lllog_site_args_(level, once, tags)); \
lllog_test_debug_()
#define lllog_test_debug_() \
if (LL_UNLIKELY(_site.shouldLog())) \
{ \
std::ostringstream* _out = LLError::Log::out(); \
(*_out)
#else
#define lllog_debug(level, once, ...) \
do { \
if (false) \
{ \
const char* tags[] = {"", ##__VA_ARGS__}; \
LLError::CallSite _site(lllog_site_args_(level, once, tags)); \
std::ostringstream* _out = LLError::Log::out(); \
(*_out)
#endif
#define lllog_site_args_(level, once, tags) \ #define lllog_site_args_(level, once, tags) \
level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), \ level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), \
__FUNCTION__, once, &tags[1], LL_ARRAY_SIZE(tags)-1 __FUNCTION__, once, &tags[1], LL_ARRAY_SIZE(tags)-1
...@@ -376,7 +418,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; ...@@ -376,7 +418,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
// NEW Macros for debugging, allow the passing of a string tag // NEW Macros for debugging, allow the passing of a string tag
// Pass comma separated list of tags (currently only supports up to 0, 1, or 2) // Pass comma separated list of tags (currently only supports up to 0, 1, or 2)
#define LL_DEBUGS(...) lllog(LLError::LEVEL_DEBUG, false, ##__VA_ARGS__) #define LL_DEBUGS(...) lllog_debug(LLError::LEVEL_DEBUG, false, ##__VA_ARGS__)
#define LL_INFOS(...) lllog(LLError::LEVEL_INFO, false, ##__VA_ARGS__) #define LL_INFOS(...) lllog(LLError::LEVEL_INFO, false, ##__VA_ARGS__)
#define LL_WARNS(...) lllog(LLError::LEVEL_WARN, false, ##__VA_ARGS__) #define LL_WARNS(...) lllog(LLError::LEVEL_WARN, false, ##__VA_ARGS__)
#define LL_ERRS(...) lllog(LLError::LEVEL_ERROR, false, ##__VA_ARGS__) #define LL_ERRS(...) lllog(LLError::LEVEL_ERROR, false, ##__VA_ARGS__)
...@@ -386,7 +428,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; ...@@ -386,7 +428,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
// Only print the log message once (good for warnings or infos that would otherwise // Only print the log message once (good for warnings or infos that would otherwise
// spam the log file over and over, such as tighter loops). // spam the log file over and over, such as tighter loops).
#define LL_DEBUGS_ONCE(...) lllog(LLError::LEVEL_DEBUG, true, ##__VA_ARGS__) #define LL_DEBUGS_ONCE(...) lllog_debug(LLError::LEVEL_DEBUG, true, ##__VA_ARGS__)
#define LL_INFOS_ONCE(...) lllog(LLError::LEVEL_INFO, true, ##__VA_ARGS__) #define LL_INFOS_ONCE(...) lllog(LLError::LEVEL_INFO, true, ##__VA_ARGS__)
#define LL_WARNS_ONCE(...) lllog(LLError::LEVEL_WARN, true, ##__VA_ARGS__) #define LL_WARNS_ONCE(...) lllog(LLError::LEVEL_WARN, true, ##__VA_ARGS__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment