diff options
author | Ruslan Teliuk <ruslantproductengine@lindenlab.com> | 2018-11-27 17:45:45 +0200 |
---|---|---|
committer | Ruslan Teliuk <ruslantproductengine@lindenlab.com> | 2018-11-27 17:45:45 +0200 |
commit | 4ab4c4498a04576a3cddf3533359a15a636b53b6 (patch) | |
tree | 064d6b7b40927a4b87803d6daf7f8db1a846ede6 /indra/llcommon/llerror.cpp | |
parent | acc86a9139872e182fbeb5b9fc7daa12c5d2c029 (diff) | |
parent | c21396181b090b626d7a9f989bcead2e517bb75f (diff) |
Merged lindenlab/viewer-cougar into default
Diffstat (limited to 'indra/llcommon/llerror.cpp')
-rw-r--r-- | indra/llcommon/llerror.cpp | 128 |
1 files changed, 108 insertions, 20 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 06c7aef8ab..49ed8b495d 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; } |