From cd52724ef8f8a19ebe28c73f39a582b56fb58093 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 28 Jun 2018 21:49:07 -0400 Subject: DRTVWR-447: Suppress BugSplat UI; auto-fill certain BugSplat data. Direct BugSplat to send crash reports without prompting, on both Windows and Mac. Add a mechanism by which code called after LL_ERRS() can retrieve the fatal log message string. (How did the crash logger extract that for Linden crash logging?) Add that fatal message to crash reports on Windows. But as BugsplatMac is engaged only on the run _after_ the crash, we no longer have that message in memory. Also add user name and region location to Windows crash reports. On Mac, (a) we don't have the information from the previous run and (b) BugsplatMac doesn't provide an API to attach that information to the crash report. Add Mac logging to indicate the success or failure of sending the crash report. Add Windows logging to indicate we're about to send. --- indra/llcommon/llerror.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index f31a054139..b5e7e81f21 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -377,6 +377,7 @@ namespace public: std::ostringstream messageStream; bool messageStreamInUse; + std::string mFatalMessage; void addCallSite(LLError::CallSite&); void invalidateCallSites(); @@ -670,11 +671,16 @@ namespace LLError s->mCrashFunction = f; } - FatalFunction getFatalFunction() - { + FatalFunction getFatalFunction() + { SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); - return s->mCrashFunction; - } + return s->mCrashFunction; + } + + std::string getFatalMessage() + { + return Globals::getInstance()->mFatalMessage; + } void setTimeFunction(TimeFunction f) { @@ -1194,7 +1200,7 @@ namespace LLError { writeToRecorders(site, "error", true, true, true, false, false); } - + std::ostringstream message_stream; if (site.mPrintOnce) @@ -1219,14 +1225,19 @@ namespace LLError s->mUniqueLogMessages[message] = 1; } } - + message_stream << message; - - writeToRecorders(site, message_stream.str()); - - if (site.mLevel == LEVEL_ERROR && s->mCrashFunction) + std::string message_line(message_stream.str()); + + writeToRecorders(site, message_line); + + if (site.mLevel == LEVEL_ERROR) { - s->mCrashFunction(message_stream.str()); + g->mFatalMessage = message_line; + if (s->mCrashFunction) + { + s->mCrashFunction(message_line); + } } } } -- cgit v1.2.3 From fc8b4ec587d8a05579244940e30b81519a1ebf91 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 26 Sep 2018 16:50:58 -0400 Subject: DRTVWR-447: Finish pulling in new viewer-release. --- indra/llcommon/llerror.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 06c7aef8ab..6dfb4bf028 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -368,6 +368,7 @@ namespace public: std::ostringstream messageStream; bool messageStreamInUse; + std::string mFatalMessage; void addCallSite(LLError::CallSite&); void invalidateCallSites(); @@ -666,11 +667,16 @@ namespace LLError s->mCrashFunction = f; } - FatalFunction getFatalFunction() - { + FatalFunction getFatalFunction() + { SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); - return s->mCrashFunction; - } + return s->mCrashFunction; + } + + std::string getFatalMessage() + { + return Globals::getInstance()->mFatalMessage; + } void setTimeFunction(TimeFunction f) { @@ -1256,12 +1262,17 @@ namespace LLError } addEscapedMessage(message_stream, message); + std::string message_line(message_stream.str()); - writeToRecorders(site, message_stream.str()); - - if (site.mLevel == LEVEL_ERROR && s->mCrashFunction) + writeToRecorders(site, message_line); + + if (site.mLevel == LEVEL_ERROR) { - s->mCrashFunction(message_stream.str()); + g->mFatalMessage = message_line; + if (s->mCrashFunction) + { + s->mCrashFunction(message_line); + } } } } -- cgit v1.2.3 From d87cc1859f3f96b98a627fdc674e297e78438681 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 11 Oct 2018 14:17:52 -0400 Subject: Modify logging so that the in-viewer console and stderr do not escape line breaks Improve the implementation so that escaping is computed only once --- indra/llcommon/llerror.cpp | 149 +++++++++++++++++++++++++++++---------------- 1 file changed, 98 insertions(+), 51 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 6dfb4bf028..668ea1f7d2 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -119,8 +119,6 @@ namespace { { LL_INFOS() << "Error setting log file to " << filename << LL_ENDL; } - mWantsTime = true; - mWantsTags = true; } ~RecordToFile() @@ -146,7 +144,7 @@ namespace { public: RecordToStderr(bool timestamp) : mUseANSI(ANSI_PROBE) { - mWantsTime = timestamp; + this->showMultiline(true); } virtual void recordMessage(LLError::ELevel level, @@ -207,7 +205,13 @@ namespace { class RecordToFixedBuffer : public LLError::Recorder { public: - RecordToFixedBuffer(LLLineBuffer* buffer) : mBuffer(buffer) { } + RecordToFixedBuffer(LLLineBuffer* buffer) + : mBuffer(buffer) + { + this->showMultiline(true); + this->showTags(false); + this->showLocation(false); + } virtual void recordMessage(LLError::ELevel level, const std::string& message) @@ -224,7 +228,11 @@ namespace { { public: RecordToWinDebug() - {} + { + this->showMultiline(true); + this->showTags(false); + this->showLocation(false); + } virtual void recordMessage(LLError::ELevel level, const std::string& message) @@ -411,8 +419,6 @@ namespace LLError public: virtual ~SettingsConfig(); - bool mPrintLocation; - LLError::ELevel mDefaultLevel; LevelMap mFunctionLevelMap; @@ -453,7 +459,6 @@ namespace LLError SettingsConfig::SettingsConfig() : LLRefCount(), - mPrintLocation(false), mDefaultLevel(LLError::LEVEL_DEBUG), mFunctionLevelMap(), mClassLevelMap(), @@ -655,12 +660,6 @@ namespace LLError commonInit(user_dir, app_dir, log_to_stderr); } - void setPrintLocation(bool print) - { - SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); - s->mPrintLocation = print; - } - void setFatalFunction(const FatalFunction& f) { SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig(); @@ -775,7 +774,6 @@ namespace LLError s->mTagLevelMap.clear(); s->mUniqueLogMessages.clear(); - setPrintLocation(config["print-location"]); setDefaultLevel(decodeLevel(config["default-level"])); LLSD sets = config["settings"]; @@ -798,11 +796,12 @@ namespace LLError namespace LLError { Recorder::Recorder() - : mWantsTime(false), - mWantsTags(false), - mWantsLevel(true), - mWantsLocation(false), - mWantsFunctionName(true) + : mWantsTime(true) + , mWantsTags(true) + , mWantsLevel(true) + , mWantsLocation(true) + , mWantsFunctionName(true) + , mWantsMultiline(false) { } @@ -839,6 +838,42 @@ namespace LLError return mWantsFunctionName; } + // virtual + bool Recorder::wantsMultiline() + { + return mWantsMultiline; + } + + void Recorder::showTime(bool show) + { + mWantsTime = show; + } + + void Recorder::showTags(bool show) + { + mWantsTags = show; + } + + void Recorder::showLevel(bool show) + { + mWantsLevel = show; + } + + void Recorder::showLocation(bool show) + { + mWantsLocation = show; + } + + void Recorder::showFunctionName(bool show) + { + mWantsFunctionName = show; + } + + void Recorder::showMultiline(bool show) + { + mWantsMultiline = show; + } + void addRecorder(RecorderPtr recorder) { if (!recorder) @@ -871,17 +906,15 @@ namespace LLError s->mFileRecorder.reset(); s->mFileRecorderFileName.clear(); - if (file_name.empty()) - { - return; - } - - RecorderPtr recordToFile(new RecordToFile(file_name)); - if (boost::dynamic_pointer_cast(recordToFile)->okay()) + if (!file_name.empty()) { - s->mFileRecorderFileName = file_name; - s->mFileRecorder = recordToFile; - addRecorder(recordToFile); + RecorderPtr recordToFile(new RecordToFile(file_name)); + if (boost::dynamic_pointer_cast(recordToFile)->okay()) + { + s->mFileRecorderFileName = file_name; + s->mFileRecorder = recordToFile; + addRecorder(recordToFile); + } } } @@ -892,14 +925,12 @@ namespace LLError removeRecorder(s->mFixedBufferRecorder); s->mFixedBufferRecorder.reset(); - if (!fixedBuffer) + if (fixedBuffer) { - return; - } - - RecorderPtr recordToFixedBuffer(new RecordToFixedBuffer(fixedBuffer)); - s->mFixedBufferRecorder = recordToFixedBuffer; - addRecorder(recordToFixedBuffer); + RecorderPtr recordToFixedBuffer(new RecordToFixedBuffer(fixedBuffer)); + s->mFixedBufferRecorder = recordToFixedBuffer; + addRecorder(recordToFixedBuffer); + } } std::string logFileName() @@ -911,8 +942,9 @@ namespace LLError namespace { - void addEscapedMessage(std::ostream& out, const std::string& message) + std::string escapedMessageLines(const std::string& message) { + std::ostringstream out; size_t written_out = 0; size_t all_content = message.length(); size_t escape_char_index; // always relative to start of message @@ -948,13 +980,16 @@ namespace // write whatever was left out << message.substr(written_out, std::string::npos); } + return out.str(); } - void writeToRecorders(const LLError::CallSite& site, const std::string& escaped_message, bool show_location = true, bool show_time = true, bool show_tags = true, bool show_level = true, bool show_function = true) + void writeToRecorders(const LLError::CallSite& site, const std::string& message) { LLError::ELevel level = site.mLevel; LLError::SettingsConfigPtr s = LLError::Settings::getInstance()->getSettingsConfig(); - + + std::string escaped_message; + for (Recorders::const_iterator i = s->mRecorders.begin(); i != s->mRecorders.end(); ++i) @@ -969,7 +1004,7 @@ namespace } message_stream << " "; - if (show_level && r->wantsLevel()) + if (r->wantsLevel()) { message_stream << site.mLevelString; } @@ -981,19 +1016,30 @@ namespace } message_stream << " "; - if (r->wantsLocation() || level == LLError::LEVEL_ERROR || s->mPrintLocation) + if (r->wantsLocation() || level == LLError::LEVEL_ERROR) { message_stream << site.mLocationString; } message_stream << " "; - if (show_function && r->wantsFunctionName()) + if (r->wantsFunctionName()) { message_stream << site.mFunctionString; } message_stream << " : "; - message_stream << escaped_message; + if (r->wantsMultiline()) + { + message_stream << message; + } + else + { + if (escaped_message.empty()) + { + escaped_message = escapedMessageLines(message); + } + message_stream << escaped_message; + } r->recordMessage(level, message_stream.str()); } @@ -1236,10 +1282,11 @@ namespace LLError delete out; } - std::ostringstream message_stream; if (site.mPrintOnce) { + std::ostringstream message_stream; + std::map::iterator messageIter = s->mUniqueLogMessages.find(message); if (messageIter != s->mUniqueLogMessages.end()) { @@ -1259,19 +1306,18 @@ namespace LLError message_stream << "ONCE: "; s->mUniqueLogMessages[message] = 1; } + message_stream << message; + message = message_stream.str(); } - addEscapedMessage(message_stream, message); - std::string message_line(message_stream.str()); - - writeToRecorders(site, message_line); + writeToRecorders(site, message); if (site.mLevel == LEVEL_ERROR) { - g->mFatalMessage = message_line; + g->mFatalMessage = message; if (s->mCrashFunction) { - s->mCrashFunction(message_line); + s->mCrashFunction(message); } } } @@ -1579,3 +1625,4 @@ bool debugLoggingEnabled(const std::string& tag) } + -- cgit v1.2.3