summaryrefslogtreecommitdiff
path: root/indra/llcommon/llerror.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2021-05-12 12:02:57 -0400
committerNat Goodspeed <nat@lindenlab.com>2021-05-12 12:02:57 -0400
commit5b96ee0e10923a00ddb3836d4dc3c5f912ca4330 (patch)
tree4eff331f4bbfa8841c1a63b3fd9dedc93323e221 /indra/llcommon/llerror.h
parent147c66d67ce83778fc3f102dd132ec095e6032fc (diff)
SL-10297: Eliminate llerror.cpp's Globals::messageStream and bool.
Instead of a single std::ostringstream instance shared by all callers, even those on different threads, make each of the relevant lllog_test_() and llcallstacks macros instantiate independent (stack) std::ostringstream objects. lllog_test_() is called by LL_DEBUGS(), LLINFOS(), LL_WARNS(), LL_ERRS(), LL_VLOGS() et al. Eliminate LLError::Log::out(), whose sole function was to arbitrate use of that shared std::ostringstream. Amusingly, if the lock couldn't be locked or if messageStreamInUse was set, out() would allocate a new (heap!) std::ostringstream anyway, which would then have to be freed by flush(). Make both LLError::Log::flush() overloads accept const std::ostringstream&. Make LL_ENDL pass the local _out instance. This eliminates the need to check whether the passed std::ostringstream* references the shared instance and (if so) reset it or (if not) delete it. Make LLError::LLCallStacks::insert() accept the local _out instance as non- const std::ostream&, rather than acquiring and returning std::ostringstream*. Make end() accept the local instance as const std::ostringstream&.
Diffstat (limited to 'indra/llcommon/llerror.h')
-rw-r--r--indra/llcommon/llerror.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h
index f8c0d03aea..51423350e6 100644
--- a/indra/llcommon/llerror.h
+++ b/indra/llcommon/llerror.h
@@ -198,9 +198,8 @@ namespace LLError
{
public:
static bool shouldLog(CallSite&);
- static std::ostringstream* out();
- static void flush(std::ostringstream* out, char* message);
- static void flush(std::ostringstream*, const CallSite&);
+ static void flush(const std::ostringstream& out, char* message);
+ static void flush(const std::ostringstream&, const CallSite&);
static std::string demangle(const char* mangled);
/// classname<TYPE>()
template <typename T>
@@ -289,10 +288,10 @@ namespace LLError
public:
static void push(const char* function, const int line) ;
- static std::ostringstream* insert(const char* function, const int line) ;
+ static void insert(std::ostream& out, const char* function, const int line) ;
static void print() ;
static void clear() ;
- static void end(std::ostringstream* _out) ;
+ static void end(const std::ostringstream& out) ;
static void cleanup();
};
@@ -306,10 +305,11 @@ namespace LLError
//this is cheaper than llcallstacks if no need to output other variables to call stacks.
#define LL_PUSH_CALLSTACKS() LLError::LLCallStacks::push(__FUNCTION__, __LINE__)
-#define llcallstacks \
- { \
- std::ostringstream* _out = LLError::LLCallStacks::insert(__FUNCTION__, __LINE__) ; \
- (*_out)
+#define llcallstacks \
+ { \
+ std::ostringstream _out; \
+ LLError::LLCallStacks::insert(_out, __FUNCTION__, __LINE__) ; \
+ _out
#define llcallstacksendl \
LLError::End(); \
@@ -355,11 +355,11 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
static LLError::CallSite _site(lllog_site_args_(level, once, tags)); \
lllog_test_()
-#define lllog_test_() \
- if (LL_UNLIKELY(_site.shouldLog())) \
- { \
- std::ostringstream* _out = LLError::Log::out(); \
- (*_out)
+#define lllog_test_() \
+ if (LL_UNLIKELY(_site.shouldLog())) \
+ { \
+ std::ostringstream _out; \
+ _out
#define lllog_site_args_(level, once, tags) \
level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), \
@@ -378,7 +378,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
// LL_CONT << " for " << t << " seconds" << LL_ENDL;
//
//Such computation is done iff the message will be logged.
-#define LL_CONT (*_out)
+#define LL_CONT _out
#define LL_NEWLINE '\n'