Skip to content
Snippets Groups Projects
Commit 37d3993a authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

MAINT-5232: Consolidate special LLSingletonBase logging logic.

parent dcdccb3e
No related branches found
No related tags found
No related merge requests found
...@@ -316,8 +316,9 @@ void intrusive_ptr_release(LLSingletonBase::MasterRefcount* mrc) ...@@ -316,8 +316,9 @@ void intrusive_ptr_release(LLSingletonBase::MasterRefcount* mrc)
} }
/*---------------------------- Logging helpers -----------------------------*/ /*---------------------------- Logging helpers -----------------------------*/
//static namespace {
void LLSingletonBase::logerrs(const char* p1, const char* p2, const char* p3, const char* p4) void log(LLError::ELevel level,
const char* p1, const char* p2, const char* p3, const char* p4)
{ {
// Check LLError::is_available() because some of LLError's infrastructure // Check LLError::is_available() because some of LLError's infrastructure
// is itself an LLSingleton. If that LLSingleton has not yet been // is itself an LLSingleton. If that LLSingleton has not yet been
...@@ -325,31 +326,30 @@ void LLSingletonBase::logerrs(const char* p1, const char* p2, const char* p3, co ...@@ -325,31 +326,30 @@ void LLSingletonBase::logerrs(const char* p1, const char* p2, const char* p3, co
// around and around we go. // around and around we go.
if (LLError::is_available()) if (LLError::is_available())
{ {
LL_ERRS() << p1 << p2 << p3 << p4 << LL_ENDL; lllog(level, false) << p1 << p2 << p3 << p4 << LL_ENDL;
} }
else else
{ {
// Caller may be a test program, or something else whose stderr is // Caller may be a test program, or something else whose stderr is
// visible to the user. // visible to the user.
std::cerr << p1 << p2 << p3 << p4 << std::endl; std::cerr << p1 << p2 << p3 << p4 << std::endl;
// The other important side effect of LL_ERRS() is
// https://www.youtube.com/watch?v=OMG7paGJqhQ (emphasis on OMG)
LLError::crashAndLoop(std::string());
} }
} }
} // anonymous namespace
//static //static
void LLSingletonBase::logwarns(const char* p1, const char* p2, const char* p3, const char* p4) void LLSingletonBase::logwarns(const char* p1, const char* p2, const char* p3, const char* p4)
{ {
// See logerrs() remarks about is_available(). log(LLError::LEVEL_WARN, p1, p2, p3, p4);
if (LLError::is_available()) }
{
LL_WARNS() << p1 << p2 << p3 << p4 << LL_ENDL; //static
} void LLSingletonBase::logerrs(const char* p1, const char* p2, const char* p3, const char* p4)
else {
{ log(LLError::LEVEL_ERROR, p1, p2, p3, p4);
std::cerr << p1 << p2 << p3 << p4 << std::endl; // The other important side effect of LL_ERRS() is
} // https://www.youtube.com/watch?v=OMG7paGJqhQ (emphasis on OMG)
LLError::crashAndLoop(std::string());
} }
std::string LLSingletonBase::demangle(const char* mangled) std::string LLSingletonBase::demangle(const char* mangled)
......
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