diff options
| -rw-r--r-- | indra/llcommon/llerror.cpp | 73 | ||||
| -rw-r--r-- | indra/llcommon/llerror.h | 30 | 
2 files changed, 26 insertions, 77 deletions
| diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 9d775dcef3..f7594ed815 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -442,8 +442,6 @@ namespace      protected:  		Globals();  	public: -		std::ostringstream messageStream; -		bool messageStreamInUse;  		std::string mFatalMessage;  		void addCallSite(LLError::CallSite&); @@ -453,12 +451,7 @@ namespace  		CallSiteVector callSites;  	}; -	Globals::Globals() -		: messageStream(), -		messageStreamInUse(false), -		callSites() -	{ -	} +	Globals::Globals() {}      Globals* Globals::getInstance()      { @@ -1359,25 +1352,7 @@ namespace LLError  	} -	std::ostringstream* Log::out() -	{ -		LLMutexTrylock lock(getMutex<LOG_MUTEX>(),5); - -		if (lock.isLocked()) -		{ -			Globals* g = Globals::getInstance(); - -			if (!g->messageStreamInUse) -			{ -				g->messageStreamInUse = true; -				return &g->messageStream; -			} -		} - -		return new std::ostringstream; -	} - -	void Log::flush(std::ostringstream* out, char* message) +	void Log::flush(const std::ostringstream& out, char* message)  	{  		LLMutexTrylock lock(getMutex<LOG_MUTEX>(),5);  		if (!lock.isLocked()) @@ -1385,31 +1360,18 @@ namespace LLError  			return;  		} -		if(strlen(out->str().c_str()) < 128) +		if(strlen(out.str().c_str()) < 128)  		{ -			strcpy(message, out->str().c_str()); +			strcpy(message, out.str().c_str());  		}  		else  		{ -			strncpy(message, out->str().c_str(), 127); +			strncpy(message, out.str().c_str(), 127);  			message[127] = '\0' ;  		} - -		Globals* g = Globals::getInstance(); -		if (out == &g->messageStream) -		{ -			g->messageStream.clear(); -			g->messageStream.str(""); -			g->messageStreamInUse = false; -		} -		else -		{ -			delete out; -		} -		return ;  	} -	void Log::flush(std::ostringstream* out, const CallSite& site) +	void Log::flush(const std::ostringstream& out, const CallSite& site)  	{  		LLMutexTrylock lock(getMutex<LOG_MUTEX>(),5);  		if (!lock.isLocked()) @@ -1420,18 +1382,7 @@ namespace LLError  		Globals* g = Globals::getInstance();  		SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); -		std::string message = out->str(); -		if (out == &g->messageStream) -		{ -			g->messageStream.clear(); -			g->messageStream.str(""); -			g->messageStreamInUse = false; -		} -		else -		{ -			delete out; -		} - +		std::string message = out.str();  		if (site.mPrintOnce)  		{ @@ -1600,15 +1551,13 @@ namespace LLError      }      //static -    std::ostringstream* LLCallStacks::insert(const char* function, const int line) +    void LLCallStacks::insert(std::ostream& out, const char* function, const int line)      { -        std::ostringstream* _out = LLError::Log::out(); -        *_out << function << " line " << line << " " ; -        return _out ; +        out << function << " line " << line << " " ;      }      //static -    void LLCallStacks::end(std::ostringstream* _out) +    void LLCallStacks::end(const std::ostringstream& out)      {          LLMutexTrylock lock(getMutex<STACKS_MUTEX>(), 5);          if (!lock.isLocked()) @@ -1626,7 +1575,7 @@ namespace LLError              clear() ;          } -        LLError::Log::flush(_out, sBuffer[sIndex++]) ; +        LLError::Log::flush(out, sBuffer[sIndex++]) ;      }      //static 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' | 
