From 42daa3497b6626cbb5f32ba54162558cd025069b Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Tue, 12 Jul 2011 15:48:02 -0700 Subject: STORM-1482 The Viewer shouldn't overwrite the crash behavior settings, some cleanups to the crash reporters, and the ability to use --set GroupName.SettingName to set parameters outside of the (default) Global settings group. --- indra/llcrashlogger/llcrashlogger.cpp | 80 +++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 31 deletions(-) (limited to 'indra/llcrashlogger/llcrashlogger.cpp') diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index 68e45f36e4..3fbaf61991 100644 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -31,10 +31,12 @@ #include "llcrashlogger.h" #include "linden_common.h" #include "llstring.h" -#include "indra_constants.h" // CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME +#include "indra_constants.h" // CRASH_BEHAVIOR_... #include "llerror.h" +#include "llerrorcontrol.h" #include "lltimer.h" #include "lldir.h" +#include "llfile.h" #include "llsdserialize.h" #include "lliopipe.h" #include "llpumpio.h" @@ -54,7 +56,7 @@ public: virtual void error(U32 status, const std::string& reason) { - gBreak = true; + gBreak = true; } virtual void result(const LLSD& content) @@ -64,19 +66,6 @@ public: } }; -bool LLCrashLoggerText::mainLoop() -{ - std::cout << "Entering main loop" << std::endl; - sendCrashLogs(); - return true; -} - -void LLCrashLoggerText::updateApplication(const std::string& message) -{ - LLCrashLogger::updateApplication(message); - std::cout << message << std::endl; -} - LLCrashLogger::LLCrashLogger() : mCrashBehavior(CRASH_BEHAVIOR_ASK), mCrashInPreviousExec(false), @@ -281,26 +270,41 @@ LLSD LLCrashLogger::constructPostData() return mCrashInfo; } +const char* const CRASH_SETTINGS_FILE = "settings_crash_behavior.xml"; + S32 LLCrashLogger::loadCrashBehaviorSetting() { std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); mCrashSettings.loadFromFile(filename); - - S32 value = mCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); - - if (value < CRASH_BEHAVIOR_ASK || CRASH_BEHAVIOR_NEVER_SEND < value) return CRASH_BEHAVIOR_ASK; - return value; + S32 value = mCrashSettings.getS32("CrashSubmitBehavior"); + + switch (value) + { + case CRASH_BEHAVIOR_NEVER_SEND: + return CRASH_BEHAVIOR_NEVER_SEND; + case CRASH_BEHAVIOR_ALWAYS_SEND: + return CRASH_BEHAVIOR_ALWAYS_SEND; + } + + return CRASH_BEHAVIOR_ASK; } bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior) { - if (crash_behavior != CRASH_BEHAVIOR_ASK && crash_behavior != CRASH_BEHAVIOR_ALWAYS_SEND) return false; + switch (crash_behavior) + { + case CRASH_BEHAVIOR_ASK: + case CRASH_BEHAVIOR_NEVER_SEND: + case CRASH_BEHAVIOR_ALWAYS_SEND: + break; + default: + return false; + } - mCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, crash_behavior); + mCrashSettings.setS32("CrashSubmitBehavior", crash_behavior); std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); - mCrashSettings.saveToFile(filename, FALSE); return true; @@ -309,14 +313,13 @@ bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior) bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout) { gBreak = false; - std::string status_message; for(int i = 0; i < retries; ++i) { - status_message = llformat("%s, try %d...", msg.c_str(), i+1); + updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); LLHTTPClient::post(host, data, new LLCrashLoggerResponder(), timeout); while(!gBreak) { - updateApplication(status_message); + updateApplication(); // No new message, just pump the IO } if(gSent) { @@ -336,7 +339,7 @@ bool LLCrashLogger::sendCrashLogs() updateApplication("Sending reports..."); std::string dump_path = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, - "SecondLifeCrashReport"); + "SecondLifeCrashReport"); std::string report_file = dump_path + ".log"; std::ofstream out_file(report_file.c_str()); @@ -365,6 +368,7 @@ void LLCrashLogger::updateApplication(const std::string& message) { gServicePump->pump(); gServicePump->callback(); + if (!message.empty()) llinfos << message << llendl; } bool LLCrashLogger::init() @@ -374,11 +378,24 @@ bool LLCrashLogger::init() // We assume that all the logs we're looking for reside on the current drive gDirUtilp->initAppDirs("SecondLife"); + LLError::initForApplication(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "")); + // Default to the product name "Second Life" (this is overridden by the -name argument) mProductName = "Second Life"; + + // Rename current log file to ".old" + std::string old_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "crashreport.log.old"); + std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "crashreport.log"); + LLFile::rename(log_file.c_str(), old_log_file.c_str()); + + // Set the log file to crashreport.log + LLError::logToFile(log_file); - mCrashSettings.declareS32(CRASH_BEHAVIOR_SETTING, CRASH_BEHAVIOR_ASK, "Controls behavior when viewer crashes " - "(0 = ask before sending crash report, 1 = always send crash report, 2 = never send crash report)"); + mCrashSettings.declareS32("CrashSubmitBehavior", CRASH_BEHAVIOR_ASK, + "Controls behavior when viewer crashes " + "(0 = ask before sending crash report, " + "1 = always send crash report, " + "2 = never send crash report)"); llinfos << "Loading crash behavior setting" << llendl; mCrashBehavior = loadCrashBehaviorSetting(); @@ -394,10 +411,11 @@ bool LLCrashLogger::init() gServicePump->prime(gAPRPoolp); LLHTTPClient::setPump(*gServicePump); - //If we've opened the crash logger, assume we can delete the marker file if it exists + //If we've opened the crash logger, assume we can delete the marker file if it exists if( gDirUtilp ) { - std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.exec_marker"); + std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, + "SecondLife.exec_marker"); LLAPRFile::remove( marker_file ); } -- cgit v1.2.3 From a517d32c4877aec79219cd346709c621c51c032b Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Fri, 15 Jul 2011 12:46:06 -0700 Subject: STORM-1482 Change the defaults, look in the app_settings dir for configs as well. --- indra/llcrashlogger/llcrashlogger.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'indra/llcrashlogger/llcrashlogger.cpp') diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index 3fbaf61991..93f3c910bd 100644 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -67,7 +67,7 @@ public: }; LLCrashLogger::LLCrashLogger() : - mCrashBehavior(CRASH_BEHAVIOR_ASK), + mCrashBehavior(CRASH_BEHAVIOR_ALWAYS_SEND), mCrashInPreviousExec(false), mCrashSettings("CrashSettings"), mSentCrashLogs(false), @@ -274,12 +274,19 @@ const char* const CRASH_SETTINGS_FILE = "settings_crash_behavior.xml"; S32 LLCrashLogger::loadCrashBehaviorSetting() { + // First check user_settings (in the user's home dir) std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); + if (! mCrashSettings.loadFromFile(filename)) + { + // Next check app_settings (in the SL program dir) + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, CRASH_SETTINGS_FILE); + mCrashSettings.loadFromFile(filename); + } - mCrashSettings.loadFromFile(filename); - + // If we didn't load any files above, this will return the default S32 value = mCrashSettings.getS32("CrashSubmitBehavior"); + // Whatever value we got, make sure it's valid switch (value) { case CRASH_BEHAVIOR_NEVER_SEND: @@ -391,14 +398,14 @@ bool LLCrashLogger::init() // Set the log file to crashreport.log LLError::logToFile(log_file); - mCrashSettings.declareS32("CrashSubmitBehavior", CRASH_BEHAVIOR_ASK, + mCrashSettings.declareS32("CrashSubmitBehavior", CRASH_BEHAVIOR_ALWAYS_SEND, "Controls behavior when viewer crashes " "(0 = ask before sending crash report, " "1 = always send crash report, " "2 = never send crash report)"); - llinfos << "Loading crash behavior setting" << llendl; - mCrashBehavior = loadCrashBehaviorSetting(); + // llinfos << "Loading crash behavior setting" << llendl; + // mCrashBehavior = loadCrashBehaviorSetting(); // If user doesn't want to send, bail out if (mCrashBehavior == CRASH_BEHAVIOR_NEVER_SEND) -- cgit v1.2.3