From 1e8f9fd80d0ac4e0eab656ed8e8e32f91ab8b533 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 24 Jul 2013 19:36:43 -0700 Subject: SH-4376 FIX: Interesting: in Statistics, replace the text "0" with "n/a" when there are no samples during the time period. added hasValue to SampleAccumulator so we don't print a value when we don't have a single sample yet added some disabled log output for scene load timing --- indra/llcommon/llerror.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index d2af004cde..5b4be1ac80 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -158,14 +158,20 @@ namespace { } private: - bool mTimestamp; - enum ANSIState {ANSI_PROBE, ANSI_YES, ANSI_NO}; - ANSIState mUseANSI; + bool mTimestamp; + enum ANSIState + { + ANSI_PROBE, + ANSI_YES, + ANSI_NO + } mUseANSI; + void colorANSI(const std::string color) { // ANSI color code escape sequence fprintf(stderr, "\033[%sm", color.c_str() ); }; + bool checkANSI(void) { #if LL_LINUX || LL_DARWIN @@ -727,13 +733,13 @@ namespace LLError namespace LLError { Recorder::~Recorder() - { } + {} // virtual bool Recorder::wantsTime() - { return false; } - - + { + return false; + } void addRecorder(Recorder* recorder) { @@ -752,9 +758,8 @@ namespace LLError return; } Settings& s = Settings::get(); - s.recorders.erase( - std::remove(s.recorders.begin(), s.recorders.end(), recorder), - s.recorders.end()); + s.recorders.erase(std::remove(s.recorders.begin(), s.recorders.end(), recorder), + s.recorders.end()); } } -- cgit v1.2.3 From a2e22732f195dc075a733c79f15156752f522a43 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 30 Jul 2013 19:13:45 -0700 Subject: Summer cleaning - removed a lot of llcommon dependencies to speed up build times consolidated most indra-specific constants in llcommon under indra_constants.h fixed issues with operations on mixed unit types (implicit and explicit) made LL_INFOS() style macros variadic in order to subsume other logging methods such as ll_infos added optional tag output to error recorders --- indra/llcommon/llerror.cpp | 171 +++++++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 51 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 5b4be1ac80..6da9df4dce 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -96,7 +96,7 @@ namespace { mFile.open(filename, llofstream::out | llofstream::app); if (!mFile) { - llinfos << "Error setting log file to " << filename << llendl; + LL_INFOS() << "Error setting log file to " << filename << LL_ENDL; } } @@ -331,7 +331,7 @@ namespace } LLError::configure(configuration); - llinfos << "logging reconfigured from " << filename() << llendl; + LL_INFOS() << "logging reconfigured from " << filename() << LL_ENDL; return true; } @@ -495,14 +495,44 @@ namespace LLError int line, const std::type_info& class_info, const char* function, + bool printOnce, const char* broadTag, - const char* narrowTag, - bool printOnce) - : mLevel(level), mFile(file), mLine(line), - mClassInfo(class_info), mFunction(function), - mCached(false), mShouldLog(false), - mBroadTag(broadTag), mNarrowTag(narrowTag), mPrintOnce(printOnce) - { } + const char* narrowTag) + : mLevel(level), + mFile(file), + mLine(line), + mClassInfo(class_info), + mFunction(function), + mCached(false), + mShouldLog(false), + mPrintOnce(printOnce), + mBroadTag(broadTag), + mNarrowTag(narrowTag) + {} + + CallSite::CallSite(ELevel level, + const char* file, + int line, + const std::type_info& class_info, + const char* function, + bool printOnce, + const char* broadTag, + const char* narrowTag, + const char*, + ...) + : mLevel(level), + mFile(file), + mLine(line), + mClassInfo(class_info), + mFunction(function), + mCached(false), + mShouldLog(false), + mPrintOnce(printOnce), + mBroadTag(broadTag), + mNarrowTag(narrowTag) + { + LL_ERRS() << "No support for more than 2 logging tags" << LL_ENDL; + } void CallSite::invalidate() @@ -677,7 +707,7 @@ namespace LLError LevelMap::const_iterator i = level_names.find(name); if (i == level_names.end()) { - llwarns << "unrecognized logging level: '" << name << "'" << llendl; + LL_WARNS() << "unrecognized logging level: '" << name << "'" << LL_ENDL; return LLError::LEVEL_INFO; } @@ -741,6 +771,12 @@ namespace LLError return false; } + // virtual + bool Recorder::wantsTags() + { + return false; + } + void addRecorder(Recorder* recorder) { if (recorder == NULL) @@ -817,11 +853,14 @@ namespace LLError namespace { - void writeToRecorders(LLError::ELevel level, const std::string& message) + void writeToRecorders(const LLError::CallSite& site, const std::string& message) { + LLError::ELevel level = site.mLevel; LLError::Settings& s = LLError::Settings::get(); std::string messageWithTime; + std::string messageWithTags; + std::string messageWithTagsAndTime; for (Recorders::const_iterator i = s.recorders.begin(); i != s.recorders.end(); @@ -829,18 +868,47 @@ namespace { LLError::Recorder* r = *i; - if (r->wantsTime() && s.timeFunction != NULL) + if (r->wantsTime() && s.timeFunction != NULL) { - if (messageWithTime.empty()) + if (r->wantsTags()) { - messageWithTime = s.timeFunction() + " " + message; + if (messageWithTagsAndTime.empty()) + { + messageWithTagsAndTime = s.timeFunction() + " " + + (site.mBroadTag ? (std::string("#") + std::string(site.mBroadTag) + " ") : std::string()) + + (site.mNarrowTag ? (std::string("#") + std::string(site.mNarrowTag) + " ") : std::string()) + + message; + } + + r->recordMessage(level, messageWithTagsAndTime); + } + else + { + if (messageWithTime.empty()) + { + messageWithTime = s.timeFunction() + " " + message; + } + + r->recordMessage(level, messageWithTime); } - - r->recordMessage(level, messageWithTime); } else { - r->recordMessage(level, message); + if (r->wantsTags()) + { + if (messageWithTags.empty()) + { + messageWithTags = (site.mBroadTag ? (std::string("#") + std::string(site.mBroadTag) + " ") : std::string()) + + (site.mNarrowTag ? (std::string("#") + std::string(site.mNarrowTag) + " ") : std::string()) + + message; + } + + r->recordMessage(level, messageWithTags); + } + else + { + r->recordMessage(level, message); + } } } } @@ -1017,10 +1085,11 @@ namespace LLError else { strncpy(message, out->str().c_str(), 127); - message[127] = '\0' ; + message[127] = '\0'; } Globals& g = Globals::get(); + if (out == &g.messageStream) { g.messageStream.clear(); @@ -1031,7 +1100,7 @@ namespace LLError { delete out; } - return ; + return; } void Log::flush(std::ostringstream* out, const CallSite& site) @@ -1063,7 +1132,7 @@ namespace LLError fatalMessage << abbreviateFile(site.mFile) << "(" << site.mLine << ") : error"; - writeToRecorders(site.mLevel, fatalMessage.str()); + writeToRecorders(site, fatalMessage.str()); } @@ -1125,7 +1194,7 @@ namespace LLError prefix << message; message = prefix.str(); - writeToRecorders(site.mLevel, message); + writeToRecorders(site, message); if (site.mLevel == LEVEL_ERROR && s.crashFunction) { @@ -1164,7 +1233,7 @@ namespace LLError { std::string::size_type i = 0; std::string::size_type len = s.length(); - for ( ; i < len; i++ ) + for (; i < len; i++ ) { if (s[i] == old) { @@ -1235,8 +1304,8 @@ namespace LLError namespace LLError { - char** LLCallStacks::sBuffer = NULL ; - S32 LLCallStacks::sIndex = 0 ; + char** LLCallStacks::sBuffer = NULL; + S32 LLCallStacks::sIndex = 0; #define SINGLE_THREADED 1 @@ -1312,34 +1381,34 @@ namespace LLError if(!sBuffer) { - sBuffer = new char*[512] ; - sBuffer[0] = new char[512 * 128] ; - for(S32 i = 1 ; i < 512 ; i++) + sBuffer = new char*[512]; + sBuffer[0] = new char[512 * 128]; + for(S32 i = 1; i < 512; i++) { - sBuffer[i] = sBuffer[i-1] + 128 ; + sBuffer[i] = sBuffer[i-1] + 128; } - sIndex = 0 ; + sIndex = 0; } if(sIndex > 511) { - clear() ; + clear(); } - strcpy(sBuffer[sIndex], function) ; - sprintf(sBuffer[sIndex] + strlen(function), " line: %d ", line) ; - sIndex++ ; + strcpy(sBuffer[sIndex], function); + sprintf(sBuffer[sIndex] + strlen(function), " line: %d ", line); + sIndex++; - return ; + return; } //static std::ostringstream* LLCallStacks::insert(const char* function, const int line) { std::ostringstream* _out = LLError::Log::out(); - *_out << function << " line " << line << " " ; + *_out << function << " line " << line << " "; - return _out ; + return _out; } //static @@ -1353,21 +1422,21 @@ namespace LLError if(!sBuffer) { - sBuffer = new char*[512] ; - sBuffer[0] = new char[512 * 128] ; - for(S32 i = 1 ; i < 512 ; i++) + sBuffer = new char*[512]; + sBuffer[0] = new char[512 * 128]; + for(S32 i = 1; i < 512; i++) { - sBuffer[i] = sBuffer[i-1] + 128 ; + sBuffer[i] = sBuffer[i-1] + 128; } - sIndex = 0 ; + sIndex = 0; } if(sIndex > 511) { - clear() ; + clear(); } - LLError::Log::flush(_out, sBuffer[sIndex++]) ; + LLError::Log::flush(_out, sBuffer[sIndex++]); } //static @@ -1381,27 +1450,27 @@ namespace LLError if(sIndex > 0) { - llinfos << " ************* PRINT OUT LL CALL STACKS ************* " << llendl ; + LL_INFOS() << " ************* PRINT OUT LL CALL STACKS ************* " << LL_ENDL; while(sIndex > 0) { - sIndex-- ; - llinfos << sBuffer[sIndex] << llendl ; + sIndex--; + LL_INFOS() << sBuffer[sIndex] << LL_ENDL; } - llinfos << " *************** END OF LL CALL STACKS *************** " << llendl ; + LL_INFOS() << " *************** END OF LL CALL STACKS *************** " << LL_ENDL; } if(sBuffer) { - delete[] sBuffer[0] ; - delete[] sBuffer ; - sBuffer = NULL ; + delete[] sBuffer[0]; + delete[] sBuffer; + sBuffer = NULL; } } //static void LLCallStacks::clear() { - sIndex = 0 ; + sIndex = 0; } #if LL_WINDOWS -- cgit v1.2.3 From 910874a7e32bdfc456474e2d0ee84d190be3011e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 30 Jul 2013 19:14:19 -0700 Subject: more cleanup --- indra/llcommon/llerror.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 6da9df4dce..947aa11e94 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -113,8 +113,6 @@ namespace { const std::string& message) { mFile << message << std::endl; - // mFile.flush(); - // *FIX: should we do this? } private: -- cgit v1.2.3 From e340009fc59d59e59b2e8d903a884acb76b178eb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 9 Aug 2013 17:11:19 -0700 Subject: second phase summer cleaning replace llinfos, lldebugs, etc with new LL_INFOS(), LL_DEBUGS(), etc. --- indra/llcommon/llerror.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 947aa11e94..652d0e212a 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -321,9 +321,9 @@ namespace if (configuration.isUndefined()) { - llwarns << filename() << " missing, ill-formed," + LL_WARNS() << filename() << " missing, ill-formed," " or simply undefined; not changing configuration" - << llendl; + << LL_ENDL; return false; } } -- cgit v1.2.3 From cc31b4ae7934010762b8aaaa7e190c74a1cd7820 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 12 Aug 2013 20:05:16 -0700 Subject: SH-4399 FIX: Interesting: Texture console MB Bound 0/384 and texture queue bounces once per second SH-4346 FIX: Interesting: some integer Statistics are displayed as floating point after crossing region boundary made llerrs/infos/etc properly variadic wrt tags LL_INFOS("A", "B", "C") works, for example fixed unit tests remove llsimplestat --- indra/llcommon/llerror.cpp | 507 ++++++++++++++++++++++----------------------- 1 file changed, 246 insertions(+), 261 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 652d0e212a..6f128d0a20 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -51,7 +51,26 @@ #include "lltimer.h" namespace { -#if !LL_WINDOWS +#if LL_WINDOWS + void debugger_print(const std::string& s) + { + // Be careful when calling OutputDebugString as it throws DBG_PRINTEXCEPTION_C + // which works just fine under the windows debugger, but can cause users who + // have enabled SEHOP exception chain validation to crash due to interactions + // between the Win 32-bit exception handling and boost coroutine fiber stacks. BUG-2707 + // + if (IsDebuggerPresent()) + { + // Need UTF16 for Unicode OutputDebugString + // + if (s.size()) + { + OutputDebugString(utf8str_to_utf16str(s).c_str()); + OutputDebugString(TEXT("\n")); + } + } + } +#else class RecordToSyslog : public LLError::Recorder { public: @@ -98,6 +117,7 @@ namespace { { LL_INFOS() << "Error setting log file to " << filename << LL_ENDL; } + mWantsTime = true; } ~RecordToFile() @@ -107,8 +127,6 @@ namespace { bool okay() { return mFile; } - virtual bool wantsTime() { return true; } - virtual void recordMessage(LLError::ELevel level, const std::string& message) { @@ -123,10 +141,11 @@ namespace { class RecordToStderr : public LLError::Recorder { public: - RecordToStderr(bool timestamp) : mTimestamp(timestamp), mUseANSI(ANSI_PROBE) { } + RecordToStderr(bool timestamp) : mUseANSI(ANSI_PROBE) + { + mWantsTime = timestamp; + } - virtual bool wantsTime() { return mTimestamp; } - virtual void recordMessage(LLError::ELevel level, const std::string& message) { @@ -156,7 +175,6 @@ namespace { } private: - bool mTimestamp; enum ANSIState { ANSI_PROBE, @@ -202,10 +220,13 @@ namespace { class RecordToWinDebug: public LLError::Recorder { public: + RecordToWinDebug() + {} + virtual void recordMessage(LLError::ELevel level, const std::string& message) { - LL_WINDOWS_OUTPUT_DEBUG(message); + debugger_print(message); } }; #endif @@ -217,7 +238,7 @@ namespace std::string className(const std::type_info& type) { #ifdef __GNUC__ - // GCC: type_info::name() returns a mangled class name, must demangle + // GCC: type_info::name() returns a mangled class name,st demangle static size_t abi_name_len = 100; static char* abi_name_buf = (char*)malloc(abi_name_len); @@ -394,25 +415,25 @@ namespace LLError class Settings { public: - bool printLocation; + bool mPrintLocation; - LLError::ELevel defaultLevel; - - LevelMap functionLevelMap; - LevelMap classLevelMap; - LevelMap fileLevelMap; - LevelMap tagLevelMap; - std::map uniqueLogMessages; - - LLError::FatalFunction crashFunction; - LLError::TimeFunction timeFunction; - - Recorders recorders; - Recorder* fileRecorder; - Recorder* fixedBufferRecorder; - std::string fileRecorderFileName; - - int shouldLogCallCounter; + LLError::ELevel mDefaultLevel; + + LevelMap mFunctionLevelMap; + LevelMap mClassLevelMap; + LevelMap mFileLevelMap; + LevelMap mTagLevelMap; + std::map mUniqueLogMessages; + + LLError::FatalFunction mCrashFunction; + LLError::TimeFunction mTimeFunction; + + Recorders mRecorders; + Recorder* mFileRecorder; + Recorder* mFixedBufferRecorder; + std::string mFileRecorderFileName; + + int mShouldLogCallCounter; static Settings& get(); @@ -422,18 +443,18 @@ namespace LLError private: Settings() - : printLocation(false), - defaultLevel(LLError::LEVEL_DEBUG), - crashFunction(), - timeFunction(NULL), - fileRecorder(NULL), - fixedBufferRecorder(NULL), - shouldLogCallCounter(0) - { } + : mPrintLocation(false), + mDefaultLevel(LLError::LEVEL_DEBUG), + mCrashFunction(), + mTimeFunction(NULL), + mFileRecorder(NULL), + mFixedBufferRecorder(NULL), + mShouldLogCallCounter(NULL) + {} ~Settings() { - for_each(recorders.begin(), recorders.end(), + for_each(mRecorders.begin(), mRecorders.end(), DeletePointer()); } @@ -494,8 +515,8 @@ namespace LLError const std::type_info& class_info, const char* function, bool printOnce, - const char* broadTag, - const char* narrowTag) + const char** tags, + size_t tag_count) : mLevel(level), mFile(file), mLine(line), @@ -504,37 +525,53 @@ namespace LLError mCached(false), mShouldLog(false), mPrintOnce(printOnce), - mBroadTag(broadTag), - mNarrowTag(narrowTag) - {} - - CallSite::CallSite(ELevel level, - const char* file, - int line, - const std::type_info& class_info, - const char* function, - bool printOnce, - const char* broadTag, - const char* narrowTag, - const char*, - ...) - : mLevel(level), - mFile(file), - mLine(line), - mClassInfo(class_info), - mFunction(function), - mCached(false), - mShouldLog(false), - mPrintOnce(printOnce), - mBroadTag(broadTag), - mNarrowTag(narrowTag) + mTags(new const char* [tag_count]), + mTagCount(tag_count) { - LL_ERRS() << "No support for more than 2 logging tags" << LL_ENDL; + for (int i = 0; i < tag_count; i++) + { + mTags[i] = tags[i]; + } + + switch (mLevel) + { + case LEVEL_DEBUG: mLevelString = "DEBUG:"; break; + case LEVEL_INFO: mLevelString = "INFO:"; break; + case LEVEL_WARN: mLevelString = "WARNING:"; break; + case LEVEL_ERROR: mLevelString = "ERROR:"; break; + default: mLevelString = "XXX:"; break; + }; + + mLocationString = llformat("%s(%d) :", abbreviateFile(mFile).c_str(), mLine); +#if LL_WINDOWS + // DevStudio: __FUNCTION__ already includes the full class name +#else +#if LL_LINUX + // gross, but typeid comparison seems to always fail here with gcc4.1 + if (0 != strcmp(site.mClassInfo.name(), typeid(NoClassInfo).name())) +#else + if (site.mClassInfo != typeid(NoClassInfo)) +#endif // LL_LINUX + { + mFunctionString = className(site.mClassInfo) + "::"; + } +#endif + mFunctionString += std::string(mFunction) + ":"; + for (size_t i = 0; i < mTagCount; i++) + { + mTagString += std::string("#") + mTags[i] + ((i == mTagCount - 1) ? "" : " "); + } } + CallSite::~CallSite() + { + delete []mTags; + } void CallSite::invalidate() - { mCached = false; } + { + mCached = false; + } } namespace @@ -620,25 +657,25 @@ namespace LLError void setPrintLocation(bool print) { Settings& s = Settings::get(); - s.printLocation = print; + s.mPrintLocation = print; } void setFatalFunction(const FatalFunction& f) { Settings& s = Settings::get(); - s.crashFunction = f; + s.mCrashFunction = f; } FatalFunction getFatalFunction() { Settings& s = Settings::get(); - return s.crashFunction; + return s.mCrashFunction; } void setTimeFunction(TimeFunction f) { Settings& s = Settings::get(); - s.timeFunction = f; + s.mTimeFunction = f; } void setDefaultLevel(ELevel level) @@ -646,13 +683,13 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); g.invalidateCallSites(); - s.defaultLevel = level; + s.mDefaultLevel = level; } ELevel getDefaultLevel() { Settings& s = Settings::get(); - return s.defaultLevel; + return s.mDefaultLevel; } void setFunctionLevel(const std::string& function_name, ELevel level) @@ -660,7 +697,7 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); g.invalidateCallSites(); - s.functionLevelMap[function_name] = level; + s.mFunctionLevelMap[function_name] = level; } void setClassLevel(const std::string& class_name, ELevel level) @@ -668,7 +705,7 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); g.invalidateCallSites(); - s.classLevelMap[class_name] = level; + s.mClassLevelMap[class_name] = level; } void setFileLevel(const std::string& file_name, ELevel level) @@ -676,7 +713,7 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); g.invalidateCallSites(); - s.fileLevelMap[file_name] = level; + s.mFileLevelMap[file_name] = level; } void setTagLevel(const std::string& tag_name, ELevel level) @@ -684,7 +721,7 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); g.invalidateCallSites(); - s.tagLevelMap[tag_name] = level; + s.mTagLevelMap[tag_name] = level; } LLError::ELevel decodeLevel(std::string name) @@ -732,11 +769,11 @@ namespace LLError Settings& s = Settings::get(); g.invalidateCallSites(); - s.functionLevelMap.clear(); - s.classLevelMap.clear(); - s.fileLevelMap.clear(); - s.tagLevelMap.clear(); - s.uniqueLogMessages.clear(); + s.mFunctionLevelMap.clear(); + s.mClassLevelMap.clear(); + s.mFileLevelMap.clear(); + s.mTagLevelMap.clear(); + s.mUniqueLogMessages.clear(); setPrintLocation(config["print-location"]); setDefaultLevel(decodeLevel(config["default-level"])); @@ -749,10 +786,10 @@ namespace LLError ELevel level = decodeLevel(entry["level"]); - setLevels(s.functionLevelMap, entry["functions"], level); - setLevels(s.classLevelMap, entry["classes"], level); - setLevels(s.fileLevelMap, entry["files"], level); - setLevels(s.tagLevelMap, entry["tags"], level); + setLevels(s.mFunctionLevelMap, entry["functions"], level); + setLevels(s.mClassLevelMap, entry["classes"], level); + setLevels(s.mFileLevelMap, entry["files"], level); + setLevels(s.mTagLevelMap, entry["tags"], level); } } } @@ -760,19 +797,44 @@ namespace LLError namespace LLError { + Recorder::Recorder() + : mWantsTime(false), + mWantsTags(false), + mWantsLevel(true), + mWantsLocation(false), + mWantsFunctionName(true) + {} + Recorder::~Recorder() {} - // virtual bool Recorder::wantsTime() { - return false; + return mWantsTime; } // virtual bool Recorder::wantsTags() { - return false; + return mWantsTags; + } + + // virtual + bool Recorder::wantsLevel() + { + return mWantsLevel; + } + + // virtual + bool Recorder::wantsLocation() + { + return mWantsLocation; + } + + // virtual + bool Recorder::wantsFunctionName() + { + return mWantsFunctionName; } void addRecorder(Recorder* recorder) @@ -782,7 +844,7 @@ namespace LLError return; } Settings& s = Settings::get(); - s.recorders.push_back(recorder); + s.mRecorders.push_back(recorder); } void removeRecorder(Recorder* recorder) @@ -792,8 +854,8 @@ namespace LLError return; } Settings& s = Settings::get(); - s.recorders.erase(std::remove(s.recorders.begin(), s.recorders.end(), recorder), - s.recorders.end()); + s.mRecorders.erase(std::remove(s.mRecorders.begin(), s.mRecorders.end(), recorder), + s.mRecorders.end()); } } @@ -803,10 +865,10 @@ namespace LLError { LLError::Settings& s = LLError::Settings::get(); - removeRecorder(s.fileRecorder); - delete s.fileRecorder; - s.fileRecorder = NULL; - s.fileRecorderFileName.clear(); + removeRecorder(s.mFileRecorder); + delete s.mFileRecorder; + s.mFileRecorder = NULL; + s.mFileRecorderFileName.clear(); if (file_name.empty()) { @@ -820,8 +882,8 @@ namespace LLError return; } - s.fileRecorderFileName = file_name; - s.fileRecorder = f; + s.mFileRecorderFileName = file_name; + s.mFileRecorder = f; addRecorder(f); } @@ -829,132 +891,114 @@ namespace LLError { LLError::Settings& s = LLError::Settings::get(); - removeRecorder(s.fixedBufferRecorder); - delete s.fixedBufferRecorder; - s.fixedBufferRecorder = NULL; + removeRecorder(s.mFixedBufferRecorder); + delete s.mFixedBufferRecorder; + s.mFixedBufferRecorder = NULL; if (!fixedBuffer) { return; } - s.fixedBufferRecorder = new RecordToFixedBuffer(fixedBuffer); - addRecorder(s.fixedBufferRecorder); + s.mFixedBufferRecorder = new RecordToFixedBuffer(fixedBuffer); + addRecorder(s.mFixedBufferRecorder); } std::string logFileName() { LLError::Settings& s = LLError::Settings::get(); - return s.fileRecorderFileName; + return s.mFileRecorderFileName; } } namespace { - void writeToRecorders(const LLError::CallSite& site, const std::string& message) + void writeToRecorders(const LLError::CallSite& site, const std::string& message, bool show_location = true, bool show_time = true, bool show_tags = true, bool show_level = true, bool show_function = true) { LLError::ELevel level = site.mLevel; LLError::Settings& s = LLError::Settings::get(); - std::string messageWithTime; - std::string messageWithTags; - std::string messageWithTagsAndTime; - - for (Recorders::const_iterator i = s.recorders.begin(); - i != s.recorders.end(); + for (Recorders::const_iterator i = s.mRecorders.begin(); + i != s.mRecorders.end(); ++i) { LLError::Recorder* r = *i; - - if (r->wantsTime() && s.timeFunction != NULL) - { - if (r->wantsTags()) - { - if (messageWithTagsAndTime.empty()) - { - messageWithTagsAndTime = s.timeFunction() + " " - + (site.mBroadTag ? (std::string("#") + std::string(site.mBroadTag) + " ") : std::string()) - + (site.mNarrowTag ? (std::string("#") + std::string(site.mNarrowTag) + " ") : std::string()) - + message; - } - - r->recordMessage(level, messageWithTagsAndTime); - } - else - { - if (messageWithTime.empty()) - { - messageWithTime = s.timeFunction() + " " + message; - } - r->recordMessage(level, messageWithTime); - } - } - else + std::ostringstream message_stream; + + if (show_location && (r->wantsLocation() || level == LLError::LEVEL_ERROR || s.mPrintLocation)) { - if (r->wantsTags()) - { - if (messageWithTags.empty()) - { - messageWithTags = (site.mBroadTag ? (std::string("#") + std::string(site.mBroadTag) + " ") : std::string()) - + (site.mNarrowTag ? (std::string("#") + std::string(site.mNarrowTag) + " ") : std::string()) - + message; - } - - r->recordMessage(level, messageWithTags); - } - else - { - r->recordMessage(level, message); - } + message_stream << site.mLocationString << " "; } - } - } -} - -/* -Recorder formats: + if (show_time && r->wantsTime() && s.mTimeFunction != NULL) + { + message_stream << s.mTimeFunction() << " "; + } -$type = "ERROR" | "WARNING" | "ALERT" | "INFO" | "DEBUG" -$loc = "$file($line)" -$msg = "$loc : " if FATAL or printing loc - "" otherwise -$msg += "$type: " -$msg += contents of stringstream + if (show_tags && r->wantsTags()) + { + message_stream << site.mTagString << " "; + } -$time = "%Y-%m-%dT%H:%M:%SZ" if UTC - or "%Y-%m-%dT%H:%M:%S %Z" if local + if (show_level && r->wantsLevel()) + { + message_stream << site.mLevelString << " "; + } + + if (show_function && r->wantsFunctionName()) + { + message_stream << site.mFunctionString << " "; + } -syslog: "$msg" -file: "$time $msg\n" -stderr: "$time $msg\n" except on windows, "$msg\n" -fixedbuf: "$msg" -winddebug: "$msg\n" + message_stream << message; -Note: if FATAL, an additional line gets logged first, with $msg set to - "$loc : error" - -You get: - llfoo.cpp(42) : error - llfoo.cpp(42) : ERROR: something - -*/ + r->recordMessage(level, message_stream.str()); + } + } +} namespace { bool checkLevelMap(const LevelMap& map, const std::string& key, LLError::ELevel& level) { + bool stop_checking; LevelMap::const_iterator i = map.find(key); if (i == map.end()) { - return false; + return stop_checking = false; } - level = i->second; - return true; + level = i->second; + return stop_checking = true; } + bool checkLevelMap( const LevelMap& map, + const char *const * keys, + size_t count, + LLError::ELevel& level) + { + bool found_level = false; + + LLError::ELevel tag_level = LLError::LEVEL_NONE; + + for (size_t i = 0; i < count; i++) + { + LevelMap::const_iterator it = map.find(keys[i]); + if (it != map.end()) + { + found_level = true; + tag_level = llmin(tag_level, it->second); + } + } + + if (found_level) + { + level = tag_level; + } + return found_level; + } + class LogLock { public: @@ -1019,10 +1063,10 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); - s.shouldLogCallCounter += 1; - - std::string class_name = className(site.mClassInfo); - std::string function_name = functionName(site.mFunction); + s.mShouldLogCallCounter++; + + std::string& class_name = className(site.mClassInfo); + std::string& function_name = functionName(site.mFunction); #if LL_LINUX // gross, but typeid comparison seems to always fail here with gcc4.1 if (0 != strcmp(site.mClassInfo.name(), typeid(NoClassInfo).name())) @@ -1033,17 +1077,18 @@ namespace LLError function_name = class_name + "::" + function_name; } - ELevel compareLevel = s.defaultLevel; + ELevel compareLevel = s.mDefaultLevel; // The most specific match found will be used as the log level, // since the computation short circuits. // So, in increasing order of importance: - // Default < Broad Tag < File < Class < Function < Narrow Tag - ((site.mNarrowTag != NULL) ? checkLevelMap(s.tagLevelMap, site.mNarrowTag, compareLevel) : false) - || checkLevelMap(s.functionLevelMap, function_name, compareLevel) - || checkLevelMap(s.classLevelMap, class_name, compareLevel) - || checkLevelMap(s.fileLevelMap, abbreviateFile(site.mFile), compareLevel) - || ((site.mBroadTag != NULL) ? checkLevelMap(s.tagLevelMap, site.mBroadTag, compareLevel) : false); + // Default < Tags < File < Class < Function + checkLevelMap(s.mFunctionLevelMap, function_name, compareLevel) + || checkLevelMap(s.mClassLevelMap, class_name, compareLevel) + || checkLevelMap(s.mFileLevelMap, abbreviateFile(site.mFile), compareLevel) + || (site.mTagCount > 0 + ? checkLevelMap(s.mTagLevelMap, site.mTags, site.mTagCount, compareLevel) + : false); site.mCached = true; g.addCallSite(site); @@ -1126,56 +1171,21 @@ namespace LLError if (site.mLevel == LEVEL_ERROR) { - std::ostringstream fatalMessage; - fatalMessage << abbreviateFile(site.mFile) - << "(" << site.mLine << ") : error"; - - writeToRecorders(site, fatalMessage.str()); + writeToRecorders(site, "error", true, true, true, false, false); } + std::ostringstream message_stream; - std::ostringstream prefix; - - switch (site.mLevel) - { - case LEVEL_DEBUG: prefix << "DEBUG: "; break; - case LEVEL_INFO: prefix << "INFO: "; break; - case LEVEL_WARN: prefix << "WARNING: "; break; - case LEVEL_ERROR: prefix << "ERROR: "; break; - default: prefix << "XXX: "; break; - }; - - if (s.printLocation) - { - prefix << abbreviateFile(site.mFile) - << "(" << site.mLine << ") : "; - } - - #if LL_WINDOWS - // DevStudio: __FUNCTION__ already includes the full class name - #else - #if LL_LINUX - // gross, but typeid comparison seems to always fail here with gcc4.1 - if (0 != strcmp(site.mClassInfo.name(), typeid(NoClassInfo).name())) - #else - if (site.mClassInfo != typeid(NoClassInfo)) - #endif // LL_LINUX - { - prefix << className(site.mClassInfo) << "::"; - } - #endif - prefix << site.mFunction << ": "; - if (site.mPrintOnce) { - std::map::iterator messageIter = s.uniqueLogMessages.find(message); - if (messageIter != s.uniqueLogMessages.end()) + std::map::iterator messageIter = s.mUniqueLogMessages.find(message); + if (messageIter != s.mUniqueLogMessages.end()) { messageIter->second++; unsigned int num_messages = messageIter->second; if (num_messages == 10 || num_messages == 50 || (num_messages % 100) == 0) { - prefix << "ONCE (" << num_messages << "th time seen): "; + message_stream << "ONCE (" << num_messages << "th time seen): "; } else { @@ -1184,26 +1194,22 @@ namespace LLError } else { - prefix << "ONCE: "; - s.uniqueLogMessages[message] = 1; + message_stream << "ONCE: "; + s.mUniqueLogMessages[message] = 1; } } - prefix << message; - message = prefix.str(); + message_stream << message; - writeToRecorders(site, message); + writeToRecorders(site, message_stream.str()); - if (site.mLevel == LEVEL_ERROR && s.crashFunction) + if (site.mLevel == LEVEL_ERROR && s.mCrashFunction) { - s.crashFunction(message); + s.mCrashFunction(message_stream.str()); } } } - - - namespace LLError { Settings* saveAndResetSettings() @@ -1260,7 +1266,7 @@ namespace LLError int shouldLogCallCount() { Settings& s = Settings::get(); - return s.shouldLogCallCounter; + return s.mShouldLogCallCounter; } #if LL_WINDOWS @@ -1471,26 +1477,5 @@ namespace LLError sIndex = 0; } -#if LL_WINDOWS - void LLOutputDebugUTF8(const std::string& s) - { - // Be careful when calling OutputDebugString as it throws DBG_PRINTEXCEPTION_C - // which works just fine under the windows debugger, but can cause users who - // have enabled SEHOP exception chain validation to crash due to interactions - // between the Win 32-bit exception handling and boost coroutine fiber stacks. BUG-2707 - // - if (IsDebuggerPresent()) - { - // Need UTF16 for Unicode OutputDebugString - // - if (s.size()) - { - OutputDebugString(utf8str_to_utf16str(s).c_str()); - OutputDebugString(TEXT("\n")); - } - } - } -#endif - } -- cgit v1.2.3 From da030893dd57bdc745330409f28a5982f453a727 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Aug 2013 17:22:29 -0700 Subject: BUILDFIX: gcc fixes --- indra/llcommon/llerror.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 6f128d0a20..1b1aada8c1 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -449,7 +449,7 @@ namespace LLError mTimeFunction(NULL), mFileRecorder(NULL), mFixedBufferRecorder(NULL), - mShouldLogCallCounter(NULL) + mShouldLogCallCounter(0) {} ~Settings() @@ -548,12 +548,12 @@ namespace LLError #else #if LL_LINUX // gross, but typeid comparison seems to always fail here with gcc4.1 - if (0 != strcmp(site.mClassInfo.name(), typeid(NoClassInfo).name())) + if (0 != strcmp(mClassInfo.name(), typeid(NoClassInfo).name())) #else - if (site.mClassInfo != typeid(NoClassInfo)) + if (mClassInfo != typeid(NoClassInfo)) #endif // LL_LINUX { - mFunctionString = className(site.mClassInfo) + "::"; + mFunctionString = className(mClassInfo) + "::"; } #endif mFunctionString += std::string(mFunction) + ":"; @@ -1065,8 +1065,8 @@ namespace LLError s.mShouldLogCallCounter++; - std::string& class_name = className(site.mClassInfo); - std::string& function_name = functionName(site.mFunction); + const std::string& class_name = className(site.mClassInfo); + std::string function_name = functionName(site.mFunction); #if LL_LINUX // gross, but typeid comparison seems to always fail here with gcc4.1 if (0 != strcmp(site.mClassInfo.name(), typeid(NoClassInfo).name())) -- cgit v1.2.3 From b1419bfbf090afa8b57d0952d98a529527c82f2d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 22 Aug 2013 16:56:14 -0700 Subject: BUILDFIX: attempted fix for crash on exit in llsdserialize test --- indra/llcommon/llerror.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 1b1aada8c1..590e236090 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -928,7 +928,8 @@ namespace if (show_location && (r->wantsLocation() || level == LLError::LEVEL_ERROR || s.mPrintLocation)) { - message_stream << site.mLocationString << " "; + message_stream << site.mLocationString; + message_stream << " "; } if (show_time && r->wantsTime() && s.mTimeFunction != NULL) -- cgit v1.2.3 From a77f42494584537489410a5157179aaadf868935 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Aug 2013 13:41:51 -0700 Subject: BUILDFIX: fix for crashes in unit tests on mac and linux --- indra/llcommon/llerror.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 590e236090..5bb6f53828 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -926,9 +926,10 @@ namespace std::ostringstream message_stream; + const_cast(site).mTagString += " "; if (show_location && (r->wantsLocation() || level == LLError::LEVEL_ERROR || s.mPrintLocation)) { - message_stream << site.mLocationString; + //message_stream << site.mLocationString; message_stream << " "; } @@ -949,12 +950,13 @@ namespace if (show_function && r->wantsFunctionName()) { - message_stream << site.mFunctionString << " "; + //message_stream << site.mFunctionString << " "; } message_stream << message; - r->recordMessage(level, message_stream.str()); + std::string final_message = message_stream.str(); + r->recordMessage(level, final_message); } } } @@ -1158,6 +1160,10 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); + //const_cast(site).mTagString += " "; + std::string tag_string = site.mTagString; + tag_string += " "; + std::string message = out->str(); if (out == &g.messageStream) { -- cgit v1.2.3 From 235cc392934f1385f05e78f09a079c431a03b4b8 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 23 Aug 2013 14:22:01 -0700 Subject: BUILDFIX: reverted some debugging changes to llerror.cpp --- indra/llcommon/llerror.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 5bb6f53828..a51f8f216a 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -929,8 +929,7 @@ namespace const_cast(site).mTagString += " "; if (show_location && (r->wantsLocation() || level == LLError::LEVEL_ERROR || s.mPrintLocation)) { - //message_stream << site.mLocationString; - message_stream << " "; + message_stream << site.mLocationString << " "; } if (show_time && r->wantsTime() && s.mTimeFunction != NULL) @@ -950,7 +949,7 @@ namespace if (show_function && r->wantsFunctionName()) { - //message_stream << site.mFunctionString << " "; + message_stream << site.mFunctionString << " "; } message_stream << message; -- cgit v1.2.3 From 7ab616c18786afcb40ab0092fe6f8c6a3a799375 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 26 Aug 2013 19:58:29 -0700 Subject: BUILDFIX: fix for windows unit test failures...don't do unnecessary manipulation of callsite strings in llerror --- indra/llcommon/llerror.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index a51f8f216a..96dbaa572a 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -926,7 +926,6 @@ namespace std::ostringstream message_stream; - const_cast(site).mTagString += " "; if (show_location && (r->wantsLocation() || level == LLError::LEVEL_ERROR || s.mPrintLocation)) { message_stream << site.mLocationString << " "; @@ -937,16 +936,16 @@ namespace message_stream << s.mTimeFunction() << " "; } - if (show_tags && r->wantsTags()) + if (show_level && r->wantsLevel()) { - message_stream << site.mTagString << " "; + message_stream << site.mLevelString << " "; } - if (show_level && r->wantsLevel()) + if (show_tags && r->wantsTags()) { - message_stream << site.mLevelString << " "; + message_stream << site.mTagString << " "; } - + if (show_function && r->wantsFunctionName()) { message_stream << site.mFunctionString << " "; @@ -954,8 +953,7 @@ namespace message_stream << message; - std::string final_message = message_stream.str(); - r->recordMessage(level, final_message); + r->recordMessage(level, message_stream.str()); } } } @@ -1159,10 +1157,6 @@ namespace LLError Globals& g = Globals::get(); Settings& s = Settings::get(); - //const_cast(site).mTagString += " "; - std::string tag_string = site.mTagString; - tag_string += " "; - std::string message = out->str(); if (out == &g.messageStream) { -- cgit v1.2.3