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.
parent
ef0d0dc2c7
commit
35b12f7547
|
|
@ -94,7 +94,12 @@ namespace {
|
|||
{
|
||||
closelog();
|
||||
}
|
||||
|
||||
|
||||
virtual bool enabled() override
|
||||
{
|
||||
return LLError::getEnabledLogTypesMask() & 0x01;
|
||||
}
|
||||
|
||||
virtual void recordMessage(LLError::ELevel level,
|
||||
const std::string& message)
|
||||
{
|
||||
|
|
@ -124,6 +129,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;
|
||||
}
|
||||
|
|
@ -133,12 +145,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:
|
||||
|
|
@ -154,6 +182,11 @@ namespace {
|
|||
mWantsTime = timestamp;
|
||||
}
|
||||
|
||||
virtual bool enabled() override
|
||||
{
|
||||
return LLError::getEnabledLogTypesMask() & 0x04;
|
||||
}
|
||||
|
||||
virtual void recordMessage(LLError::ELevel level,
|
||||
const std::string& message)
|
||||
{
|
||||
|
|
@ -217,6 +250,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)
|
||||
{
|
||||
|
|
@ -234,6 +272,11 @@ namespace {
|
|||
RecordToWinDebug()
|
||||
{}
|
||||
|
||||
virtual bool enabled() override
|
||||
{
|
||||
return LLError::getEnabledLogTypesMask() & 0x10;
|
||||
}
|
||||
|
||||
virtual void recordMessage(LLError::ELevel level,
|
||||
const std::string& message)
|
||||
{
|
||||
|
|
@ -421,7 +464,11 @@ namespace LLError
|
|||
bool mPrintLocation;
|
||||
|
||||
LLError::ELevel mDefaultLevel;
|
||||
|
||||
|
||||
bool mLogAlwaysFlush;
|
||||
|
||||
U32 mEnabledLogTypesMask;
|
||||
|
||||
LevelMap mFunctionLevelMap;
|
||||
LevelMap mClassLevelMap;
|
||||
LevelMap mFileLevelMap;
|
||||
|
|
@ -462,6 +509,8 @@ namespace LLError
|
|||
: LLRefCount(),
|
||||
mPrintLocation(false),
|
||||
mDefaultLevel(LLError::LEVEL_DEBUG),
|
||||
mLogAlwaysFlush(true),
|
||||
mEnabledLogTypesMask(0xFFFFFFFF),
|
||||
mFunctionLevelMap(),
|
||||
mClassLevelMap(),
|
||||
mFileLevelMap(),
|
||||
|
|
@ -652,6 +701,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);
|
||||
|
||||
|
|
@ -725,6 +776,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();
|
||||
|
|
@ -805,7 +880,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)
|
||||
|
|
@ -949,7 +1032,12 @@ namespace
|
|||
++i)
|
||||
{
|
||||
LLError::RecorderPtr r = *i;
|
||||
|
||||
|
||||
if (!r->enabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::ostringstream message_stream;
|
||||
|
||||
if (show_time && r->wantsTime() && s->mTimeFunction != NULL)
|
||||
|
|
@ -1033,6 +1121,7 @@ namespace {
|
|||
|
||||
namespace LLError
|
||||
{
|
||||
|
||||
bool Log::shouldLog(CallSite& site)
|
||||
{
|
||||
LLMutexTrylock lock( &gLogMutex,5);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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>true</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 -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue