Skip to content
Snippets Groups Projects
Commit a6f31e91 authored by Brad Kittenbrink's avatar Brad Kittenbrink Committed by Nat Goodspeed
Browse files

Fixed variadic macro usage in LL_ERRS_IF and LL_WARNS_IF and improved...

Fixed variadic macro usage in LL_ERRS_IF and LL_WARNS_IF and improved LLError::shouldLogToStderr() behavior under xcode.
parent 6992ad45
No related branches found
No related tags found
No related merge requests found
...@@ -664,10 +664,10 @@ namespace ...@@ -664,10 +664,10 @@ namespace
// console log. It's generally considered bad form to spam too much // console log. It's generally considered bad form to spam too much
// there. // there.
// If stdin is a tty, assume the user launched from the command line and // If stderr is a tty, assume the user launched from the command line or
// therefore wants to see stderr. Otherwise, assume we've been launched // debugger and therefore wants to see stderr. Otherwise, assume we've
// from the finder and shouldn't spam stderr. // been launched from the finder and shouldn't spam stderr.
return isatty(0); return isatty(STDERR_FILENO);
#else #else
return true; return true;
#endif #endif
......
...@@ -381,8 +381,13 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; ...@@ -381,8 +381,13 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
#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__)
// alternative to llassert_always that prints explanatory message // alternative to llassert_always that prints explanatory message
#define LL_WARNS_IF(exp, ...) if (exp) LL_WARNS(##__VA_ARGS__) << "(" #exp ")" // note ## token paste operator hack used above will only work in gcc following
#define LL_ERRS_IF(exp, ...) if (exp) LL_ERRS(##__VA_ARGS__) << "(" #exp ")" // a comma and is completely unnecessary in VS since the comma is automatically
// suppressed
// https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
// https://docs.microsoft.com/en-us/cpp/preprocessor/variadic-macros?view=vs-2015
#define LL_WARNS_IF(exp, ...) if (exp) LL_WARNS(__VA_ARGS__) << "(" #exp ")"
#define LL_ERRS_IF(exp, ...) if (exp) LL_ERRS(__VA_ARGS__) << "(" #exp ")"
// 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).
......
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