diff options
| author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2018-11-14 16:20:05 +0200 | 
|---|---|---|
| committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2018-11-14 16:20:05 +0200 | 
| commit | 39652180aea043b4e8d0cb1f9a2a484e5ce2a471 (patch) | |
| tree | 9a2c286caf4e05eb30870e462e04cdf0c4b46f9b /indra/llcommon | |
| parent | ccd20624e37d74217b5d633fb74ebc81672c53f5 (diff) | |
| parent | 34770cbf2ef34b7901552057a0823e502d42be1d (diff) | |
Merged in lindenlab/axon
Diffstat (limited to 'indra/llcommon')
| -rw-r--r-- | indra/llcommon/llcallstack.h | 7 | ||||
| -rw-r--r-- | indra/llcommon/llerror.cpp | 128 | ||||
| -rw-r--r-- | indra/llcommon/llerrorcontrol.h | 6 | ||||
| -rw-r--r-- | indra/llcommon/llmemory.h | 6 | ||||
| -rw-r--r-- | indra/llcommon/llstring.cpp | 19 | ||||
| -rw-r--r-- | indra/llcommon/llstring.h | 3 | 
6 files changed, 149 insertions, 20 deletions
| diff --git a/indra/llcommon/llcallstack.h b/indra/llcommon/llcallstack.h index 1f7a7689d7..5acf04a49f 100644 --- a/indra/llcommon/llcallstack.h +++ b/indra/llcommon/llcallstack.h @@ -78,3 +78,10 @@ struct LLContextStatus  };  LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLContextStatus& context_status); + +#define dumpStack(tag) \ +    if (debugLoggingEnabled(tag)) \ +    { \ +        LLCallStack cs; \ +        LL_DEBUGS(tag) << "STACK:\n" << "====================\n" << cs << "====================" << LL_ENDL; \ +    } diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 64288e114b..40eb7d9bac 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -29,6 +29,7 @@  #include "llerror.h"  #include "llerrorcontrol.h" +#include "llsdutil.h"  #include <cctype>  #ifdef __GNUC__ @@ -89,9 +90,14 @@ namespace {  		{  			closelog();  		} -		 + +        virtual bool enabled() override +        { +            return LLError::getEnabledLogTypesMask() & 0x01; +        } +          		virtual void recordMessage(LLError::ELevel level, -									const std::string& message) +									const std::string& message) override  		{  			int syslogPriority = LOG_CRIT;  			switch (level) { @@ -119,6 +125,13 @@ namespace {  			{  				LL_INFOS() << "Error setting log file to " << filename << LL_ENDL;  			} +            else +            { +                if (!LLError::getAlwaysFlush()) +                { +                    mFile.sync_with_stdio(false); +                } +            }  			mWantsTime = true;              mWantsTags = true;  		} @@ -128,12 +141,28 @@ namespace {  			mFile.close();  		} +        virtual bool enabled() override +        { +#ifdef LL_RELEASE_FOR_DOWNLOAD +            return 1; +#else +            return LLError::getEnabledLogTypesMask() & 0x02; +#endif +        } +          		bool okay() { return mFile.good(); }  		virtual void recordMessage(LLError::ELevel level, -									const std::string& message) +									const std::string& message) override  		{ -			mFile << message << std::endl; +            if (LLError::getAlwaysFlush()) +            { +                mFile << message << std::endl; +            } +            else +            { +                mFile << message << "\n"; +            }  		}  	private: @@ -149,8 +178,13 @@ namespace {  			mWantsTime = timestamp;  		} +        virtual bool enabled() override +        { +            return LLError::getEnabledLogTypesMask() & 0x04; +        } +          		virtual void recordMessage(LLError::ELevel level, -					   const std::string& message) +					   const std::string& message) override  		{  			if (ANSI_PROBE == mUseANSI)  				mUseANSI = (checkANSI() ? ANSI_YES : ANSI_NO); @@ -209,8 +243,13 @@ namespace {  	public:  		RecordToFixedBuffer(LLLineBuffer* buffer) : mBuffer(buffer) { } +        virtual bool enabled() override +        { +            return LLError::getEnabledLogTypesMask() & 0x08; +        } +          		virtual void recordMessage(LLError::ELevel level, -								   const std::string& message) +								   const std::string& message) override  		{  			mBuffer->addLine(message);  		} @@ -226,8 +265,13 @@ namespace {  		RecordToWinDebug()  		{} +        virtual bool enabled() override +        { +            return LLError::getEnabledLogTypesMask() & 0x10; +        } +          		virtual void recordMessage(LLError::ELevel level, -								   const std::string& message) +								   const std::string& message) override  		{  			debugger_print(message);  		} @@ -394,7 +438,7 @@ namespace  			 i != callSites.end();  			 ++i)  		{ -			(*i)->invalidate(); +            (*i)->invalidate();  		}  		callSites.clear(); @@ -413,7 +457,11 @@ namespace LLError  		bool                                mPrintLocation;  		LLError::ELevel                     mDefaultLevel; -		 + +        bool 								mLogAlwaysFlush; + +        U32 								mEnabledLogTypesMask; +  		LevelMap                            mFunctionLevelMap;  		LevelMap                            mClassLevelMap;  		LevelMap                            mFileLevelMap; @@ -454,6 +502,8 @@ namespace LLError  		: LLRefCount(),  		mPrintLocation(false),  		mDefaultLevel(LLError::LEVEL_DEBUG), +		mLogAlwaysFlush(true), +		mEnabledLogTypesMask(255),  		mFunctionLevelMap(),  		mClassLevelMap(),  		mFileLevelMap(), @@ -618,6 +668,8 @@ namespace  		LLError::Settings::getInstance()->reset();  		LLError::setDefaultLevel(LLError::LEVEL_INFO); +        LLError::setAlwaysFlush(true); +        LLError::setEnabledLogTypesMask(0xFFFFFFFF);  		LLError::setFatalFunction(LLError::crashAndLoop);  		LLError::setTimeFunction(LLError::utcTime); @@ -691,6 +743,30 @@ namespace LLError  		return s->mDefaultLevel;  	} +	void setAlwaysFlush(bool flush) +	{ +		SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); +		s->mLogAlwaysFlush = flush; +	} + +	bool getAlwaysFlush() +	{ +		SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); +		return s->mLogAlwaysFlush; +	} + +	void setEnabledLogTypesMask(U32 mask) +	{ +		SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); +		s->mEnabledLogTypesMask = mask; +	} + +	U32 getEnabledLogTypesMask() +	{ +		SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); +		return s->mEnabledLogTypesMask; +	} +  	void setFunctionLevel(const std::string& function_name, ELevel level)  	{  		Globals::getInstance()->invalidateCallSites(); @@ -771,7 +847,15 @@ namespace LLError  		setPrintLocation(config["print-location"]);  		setDefaultLevel(decodeLevel(config["default-level"])); -		 +        if (config.has("log-always-flush")) +        { +            setAlwaysFlush(config["log-always-flush"]); +        } +        if (config.has("enabled-log-types-mask")) +        { +            setEnabledLogTypesMask(config["enabled-log-types-mask"].asInteger()); +        } +          		LLSD sets = config["settings"];  		LLSD::array_const_iterator a, end;  		for (a = sets.beginArray(), end = sets.endArray(); a != end; ++a) @@ -954,7 +1038,12 @@ namespace  			++i)  		{  			LLError::RecorderPtr r = *i; -			 + +            if (!r->enabled()) +            { +                continue; +            } +              			std::ostringstream message_stream;  			if (r->wantsTime() && s->mTimeFunction != NULL) @@ -1088,6 +1177,7 @@ namespace {  namespace LLError  { +  	bool Log::shouldLog(CallSite& site)  	{  		LogLock lock; @@ -1553,18 +1643,16 @@ namespace LLError  bool debugLoggingEnabled(const std::string& tag)  { -    const char* tags[] = {tag.c_str()}; -    ::size_t tag_count = 1; -    LLError::CallSite _site(LLError::LEVEL_DEBUG, __FILE__, __LINE__,  -                            typeid(_LL_CLASS_TO_LOG), __FUNCTION__, false, tags, tag_count); -    if (LL_UNLIKELY(_site.shouldLog())) -    { -        return true; -    } -    else +    LogLock lock; +    if (!lock.ok())      {          return false;      } +         +    LLError::SettingsConfigPtr s = LLError::Settings::getInstance()->getSettingsConfig(); +    LLError::ELevel level = LLError::LEVEL_DEBUG; +    bool res = checkLevelMap(s->mTagLevelMap, tag, level); +    return res;  } diff --git a/indra/llcommon/llerrorcontrol.h b/indra/llcommon/llerrorcontrol.h index caf2ba72c2..1730f0c640 100644 --- a/indra/llcommon/llerrorcontrol.h +++ b/indra/llcommon/llerrorcontrol.h @@ -74,6 +74,10 @@ namespace LLError  	LL_COMMON_API void setPrintLocation(bool);  	LL_COMMON_API void setDefaultLevel(LLError::ELevel);  	LL_COMMON_API ELevel getDefaultLevel(); +	LL_COMMON_API void setAlwaysFlush(bool flush); +    LL_COMMON_API bool getAlwaysFlush(); +	LL_COMMON_API void setEnabledLogTypesMask(U32 mask); +	LL_COMMON_API U32 getEnabledLogTypesMask();  	LL_COMMON_API void setFunctionLevel(const std::string& function_name, LLError::ELevel);  	LL_COMMON_API void setClassLevel(const std::string& class_name, LLError::ELevel);  	LL_COMMON_API void setFileLevel(const std::string& file_name, LLError::ELevel); @@ -140,6 +144,8 @@ namespace LLError  		virtual void recordMessage(LLError::ELevel, const std::string& message) = 0;  			// use the level for better display, not for filtering +        virtual bool enabled() { return true; } +  		bool wantsTime();  		bool wantsTags();  		bool wantsLevel(); diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 5b17d9e3a4..f04ae5f5cb 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -60,6 +60,12 @@ class LLMutex ;  LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);  #ifdef SHOW_ASSERT +// This is incredibly expensive - in profiling Windows RWD builds, 30% +// of CPU time was in aligment checks. +//#define ASSERT_ALIGNMENT +#endif + +#ifdef ASSERT_ALIGNMENT  #define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(uintptr_t(ptr),((U32)alignment))  #else  #define ll_assert_aligned(ptr,alignment) diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index c45db3b185..9a02fecd72 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -869,6 +869,25 @@ std::string LLStringOps::getDatetimeCode (std::string key)  	}  } +std::string LLStringOps::getReadableNumber(F64 num) +{ +    if (fabs(num)>=1e9) +    { +		return llformat("%.2lfB", num / 1e9); +    } +    else if (fabs(num)>=1e6) +    { +		return llformat("%.2lfM", num / 1e6); +    } +    else if (fabs(num)>=1e3) +    { +		return llformat("%.2lfK", num / 1e3); +    } +    else +    { +		return llformat("%.2lf", num); +    } +}  namespace LLStringFn  { diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index a4a5b393cb..68ee9db46b 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -211,6 +211,9 @@ public:  	static bool getPacificDaylightTime(void) { return sPacificDaylightTime;}  	static std::string getDatetimeCode (std::string key); + +    // Express a value like 1234567 as "1.23M"  +    static std::string getReadableNumber(F64 num);  };  /** | 
