diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2016-09-01 15:21:54 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2016-09-01 15:21:54 -0400 |
commit | 31d3d654f156351e3cf29f97fd97cbda046ae650 (patch) | |
tree | 78fbef8bc2cf4e411aa291b7e346b1fdbe11df36 /indra | |
parent | 4fb100ac7a33174883184f1320d0beac08ead3a7 (diff) |
MAINT-5011: Advise against lllog() instead of (e.g.) LL_INFOS().
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/llerror.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index 3beef65723..8e13ec6431 100644 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -305,22 +305,31 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; ///////////////////////////////// // Error Logging Macros -// See top of file for common usage. +// See top of file for common usage. ///////////////////////////////// -// this macro uses a one-shot do statement to avoid parsing errors when writing control flow statements -// without braces: -// if (condition) LL_INFOS() << "True" << LL_ENDL; else LL_INFOS()() << "False" << LL_ENDL - -#define lllog(level, once, ...) \ - do { \ - const char* tags[] = {"", ##__VA_ARGS__}; \ - ::size_t tag_count = LL_ARRAY_SIZE(tags) - 1; \ - static LLError::CallSite _site( \ - level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), __FUNCTION__, once, &tags[1], tag_count);\ - if (LL_UNLIKELY(_site.shouldLog())) \ - { \ - std::ostringstream* _out = LLError::Log::out(); \ +// Instead of using LL_DEBUGS(), LL_INFOS() et al., it may be tempting to +// directly code the lllog() macro so you can pass in the LLError::ELevel as a +// variable. DON'T DO IT! The reason is that the first time control passes +// through lllog(), it initializes a local static LLError::CallSite with that +// *first* ELevel value. All subsequent visits will decide whether or not to +// emit output based on the *first* ELevel value bound into that static +// CallSite instance. lllog() assumes its ELevel argument never varies. + +// this macro uses a one-shot do statement to avoid parsing errors when +// writing control flow statements without braces: +// if (condition) LL_INFOS() << "True" << LL_ENDL; else LL_INFOS()() << "False" << LL_ENDL; + +#define lllog(level, once, ...) \ + do { \ + const char* tags[] = {"", ##__VA_ARGS__}; \ + ::size_t tag_count = LL_ARRAY_SIZE(tags) - 1; \ + static LLError::CallSite _site( \ + level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), \ + __FUNCTION__, once, &tags[1], tag_count); \ + if (LL_UNLIKELY(_site.shouldLog())) \ + { \ + std::ostringstream* _out = LLError::Log::out(); \ (*_out) //Use this construct if you need to do computation in the middle of a |