diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2018-08-24 21:55:07 +0100 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2018-08-24 21:55:07 +0100 |
commit | 9c6678b5e76c485ae915b539327069b43185e16f (patch) | |
tree | ee553de5e9069e9c63253b6341e3c67b8c751ac7 /indra/llcommon | |
parent | d1338384704fdd29a79500a0ed8a21c764d229c2 (diff) |
SL-944 - logcontrol options to control which log recorders get used. This can be useful for performance reasons when especially verbose debug logging is needed.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llerror.cpp | 99 | ||||
-rw-r--r-- | indra/llcommon/llerrorcontrol.h | 6 |
2 files changed, 100 insertions, 5 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index ba71f4ddfb..3e4dd708a8 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -89,7 +89,12 @@ namespace { { closelog(); } - + + virtual bool enabled() override + { + return LLError::getEnabledLogTypesMask() & 0x01; + } + virtual void recordMessage(LLError::ELevel level, const std::string& message) { @@ -119,6 +124,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 +140,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) { - mFile << message << std::endl; + if (LLError::getAlwaysFlush()) + { + mFile << message << std::endl; + } + else + { + mFile << message << "\n"; + } } private: @@ -149,6 +177,11 @@ namespace { mWantsTime = timestamp; } + virtual bool enabled() override + { + return LLError::getEnabledLogTypesMask() & 0x04; + } + virtual void recordMessage(LLError::ELevel level, const std::string& message) { @@ -209,6 +242,11 @@ 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) { @@ -226,6 +264,11 @@ namespace { RecordToWinDebug() {} + virtual bool enabled() override + { + return LLError::getEnabledLogTypesMask() & 0x10; + } + virtual void recordMessage(LLError::ELevel level, const std::string& message) { @@ -413,7 +456,11 @@ namespace LLError bool mPrintLocation; LLError::ELevel mDefaultLevel; - + + bool mLogAlwaysFlush; + + U32 mEnabledLogTypesMask; + LevelMap mFunctionLevelMap; LevelMap mClassLevelMap; LevelMap mFileLevelMap; @@ -454,6 +501,8 @@ namespace LLError : LLRefCount(), mPrintLocation(false), mDefaultLevel(LLError::LEVEL_DEBUG), + mLogAlwaysFlush(true), + mEnabledLogTypesMask(0xFFFFFFFF), mFunctionLevelMap(), mClassLevelMap(), mFileLevelMap(), @@ -613,6 +662,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); @@ -686,6 +737,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(); @@ -766,7 +841,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) @@ -910,7 +993,12 @@ namespace ++i) { LLError::RecorderPtr r = *i; - + + if (!r->enabled()) + { + continue; + } + std::ostringstream message_stream; if (show_time && r->wantsTime() && s->mTimeFunction != NULL) @@ -1039,6 +1127,7 @@ namespace { namespace LLError { + bool Log::shouldLog(CallSite& site) { LogLock lock; 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(); |