summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llcommon/llerror.cpp99
-rw-r--r--indra/llcommon/llerrorcontrol.h6
-rw-r--r--indra/newview/app_settings/logcontrol.xml15
3 files changed, 115 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();
diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index ae57e125bb..08741327a5 100644
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -3,6 +3,21 @@
<!-- default-level can be ALL, DEBUG, INFO, WARN, ERROR, or NONE -->
<key>default-level</key> <string>INFO</string>
<key>print-location</key> <boolean>false</boolean>
+ <key>log-always-flush</key> <boolean>true</boolean>
+ <!-- All log types are enabled by default. Can be toggled individually;
+ bitwise-or all the ones you want to enable.
+ Log types and their masks are:
+
+ 1 - RecordToSyslog (not used by viewer)
+ 2 - RecordToFile (SecondLife.log)
+ 4 - RecordToStderr (this will appear in the console window, if there is one)
+ 8 - RecordToFixedBuffer (viewer debug console)
+ 16 - RecordToWinDebug (on windows, output to VS IDE window)
+
+ For example, value of 10 = 2|8 would enable logging only to SecondLife.log and the viewer debug console.
+ Note: RecordToFile is always enabled in release builds.
+ -->
+ <key>enabled-log-types-mask</key> <integer>0xFFFFFFFF</integer>
<key>settings</key>
<array>
<!-- Suppress anything but ERROR for some very verbose components -->