From 37d3993a59f01bae55049b08d196733121b54f7f Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Tue, 30 Aug 2016 16:42:24 -0400
Subject: [PATCH] MAINT-5232: Consolidate special LLSingletonBase logging
 logic.

---
 indra/llcommon/llsingleton.cpp | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp
index 8c8ded0e510..c3e8f6c7c72 100644
--- a/indra/llcommon/llsingleton.cpp
+++ b/indra/llcommon/llsingleton.cpp
@@ -316,8 +316,9 @@ void intrusive_ptr_release(LLSingletonBase::MasterRefcount* mrc)
 }
 
 /*---------------------------- Logging helpers -----------------------------*/
-//static
-void LLSingletonBase::logerrs(const char* p1, const char* p2, const char* p3, const char* p4)
+namespace {
+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
     // 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
     // around and around we go.
     if (LLError::is_available())
     {
-        LL_ERRS() << p1 << p2 << p3 << p4 << LL_ENDL;
+        lllog(level, false) << p1 << p2 << p3 << p4 << LL_ENDL;
     }
     else
     {
         // Caller may be a test program, or something else whose stderr is
         // visible to the user.
         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
 void LLSingletonBase::logwarns(const char* p1, const char* p2, const char* p3, const char* p4)
 {
-    // See logerrs() remarks about is_available().
-    if (LLError::is_available())
-    {
-        LL_WARNS() << p1 << p2 << p3 << p4 << LL_ENDL;
-    }
-    else
-    {
-        std::cerr << p1 << p2 << p3 << p4 << std::endl;
-    }
+    log(LLError::LEVEL_WARN, p1, p2, p3, p4);
+}
+
+//static
+void LLSingletonBase::logerrs(const char* p1, const char* p2, const char* p3, const char* p4)
+{
+    log(LLError::LEVEL_ERROR, p1, p2, p3, p4);
+    // 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)
-- 
GitLab