summaryrefslogtreecommitdiff
path: root/indra/llcrashlogger
diff options
context:
space:
mode:
authorAndrew A. de Laix <alain@lindenlab.com>2010-06-03 14:57:04 -0700
committerAndrew A. de Laix <alain@lindenlab.com>2010-06-03 14:57:04 -0700
commit6b9442a88da27181b2692528ff74e0d0c0985cdd (patch)
treea1b1c9cc282309475729581b26371264e40d6376 /indra/llcrashlogger
parent792b9d38cbf5fc5d03339c255a13912fa85bee51 (diff)
parentf9468db62e848b9d5d3aae54355e522bd6be10e4 (diff)
Automated merge with ssh://hg.lindenlab.com/brad/viewer-public
Diffstat (limited to 'indra/llcrashlogger')
-rwxr-xr-xindra/llcrashlogger/llcrashlogger.cpp88
-rwxr-xr-xindra/llcrashlogger/llcrashlogger.h1
2 files changed, 59 insertions, 30 deletions
diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp
index 51e5f14bfe..89ebf0eccb 100755
--- a/indra/llcrashlogger/llcrashlogger.cpp
+++ b/indra/llcrashlogger/llcrashlogger.cpp
@@ -36,6 +36,8 @@
#include "llcrashlogger.h"
#include "linden_common.h"
+#include "lldate.h"
+#include "llfile.h"
#include "llstring.h"
#include "indra_constants.h" // CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME
#include "llerror.h"
@@ -153,54 +155,79 @@ std::string getStartupStateFromLog(std::string& sllog)
return startup_state;
}
-void LLCrashLogger::gatherFiles()
+void LLCrashLogger::findAndRenameLogFiles()
{
- updateApplication("Gathering logs...");
+ // Find and rename the relevant log files so they won't be stomped on if
+ // SL is restarted before user sends crash report.
+
+ std::string now = "." + LLDate::now().asString();
+
+ std::string stats_log_original = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stats.log");
+ std::string stats_log = stats_log_original;
+ stats_log.insert(stats_log.length() - 4, now);
+ if(LLFile::rename(stats_log_original, stats_log) == 0)
+ {
+ mFileMap["StatsLog"] = stats_log;
+ }
+
+ std::string second_life_log_original;
+ std::string settings_file_original;
- // Figure out the filename of the debug log
- std::string db_file_name = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"debug_info.log");
+ std::string db_file_name_original = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"debug_info.log");
+ std::string db_file_name = db_file_name_original;
+ db_file_name.insert(db_file_name.length() - 4, now);
+ LLFile::rename(db_file_name_original, db_file_name);
std::ifstream debug_log_file(db_file_name.c_str());
-
- // Look for it in the debug_info.log file
if (debug_log_file.is_open())
{
- LLSDSerialize::fromXML(mDebugLog, debug_log_file);
-
+ LLSDSerialize::fromXML(mDebugLog, debug_log_file);
mCrashInPreviousExec = mDebugLog["CrashNotHandled"].asBoolean();
-
- mFileMap["SecondLifeLog"] = mDebugLog["SLLog"].asString();
- mFileMap["SettingsXml"] = mDebugLog["SettingsFilename"].asString();
- if(mDebugLog.has("CAFilename"))
- {
- LLCurl::setCAFile(mDebugLog["CAFilename"].asString());
- }
- else
- {
- LLCurl::setCAFile(gDirUtilp->getCAFile());
- }
-
- llinfos << "Using log file from debug log " << mFileMap["SecondLifeLog"] << llendl;
- llinfos << "Using settings file from debug log " << mFileMap["SettingsXml"] << llendl;
+ second_life_log_original = mDebugLog["SLLog"].asString();
+ settings_file_original = mDebugLog["SettingsFilename"].asString();
}
else
{
// Figure out the filename of the second life log
- LLCurl::setCAFile(gDirUtilp->getCAFile());
- mFileMap["SecondLifeLog"] = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.log");
- mFileMap["SettingsXml"] = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,"settings.xml");
+ second_life_log_original = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.log");
+ settings_file_original = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,"settings.xml");
}
-
+
if(mCrashInPreviousExec)
{
// Restarting after freeze.
// Replace the log file ext with .old, since the
// instance that launched this process has overwritten
// SecondLife.log
- std::string log_filename = mFileMap["SecondLifeLog"];
- log_filename.replace(log_filename.size() - 4, 4, ".old");
- mFileMap["SecondLifeLog"] = log_filename;
+ second_life_log_original.replace(second_life_log_original.size() - 4, 4, ".old");
}
+
+ std::string second_life_log = second_life_log_original;
+ std::string settings_file = settings_file_original;
+ second_life_log.insert(second_life_log.length() - 4, now);
+ settings_file.insert(settings_file.length() - 4, now);
+ if(LLFile::rename(second_life_log_original, second_life_log) == 0)
+ {
+ mFileMap["SecondLifeLog"] = second_life_log;
+ }
+ if(LLFile::rename(settings_file_original, settings_file) == 0)
+ {
+ mFileMap["SettingsXml"] = settings_file;
+ }
+}
+
+void LLCrashLogger::gatherFiles()
+{
+ updateApplication("Gathering logs...");
+ if(mDebugLog.has("CAFilename"))
+ {
+ LLCurl::setCAFile(mDebugLog["CAFilename"].asString());
+ }
+ else
+ {
+ LLCurl::setCAFile(gDirUtilp->getCAFile());
+ }
+
gatherPlatformSpecificFiles();
//Use the debug log to reconstruct the URL to send the crash report to
@@ -230,7 +257,6 @@ void LLCrashLogger::gatherFiles()
mAltCrashHost = "https://login.agni.lindenlab.com:12043/crash/report";
mCrashInfo["DebugLog"] = mDebugLog;
- mFileMap["StatsLog"] = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stats.log");
updateApplication("Encoding files...");
@@ -405,5 +431,7 @@ bool LLCrashLogger::init()
LLAPRFile::remove( marker_file );
}
+ findAndRenameLogFiles();
+
return true;
}
diff --git a/indra/llcrashlogger/llcrashlogger.h b/indra/llcrashlogger/llcrashlogger.h
index f8abe20597..a3cb17a958 100755
--- a/indra/llcrashlogger/llcrashlogger.h
+++ b/indra/llcrashlogger/llcrashlogger.h
@@ -48,6 +48,7 @@ public:
S32 loadCrashBehaviorSetting();
void gatherFiles();
virtual void gatherPlatformSpecificFiles() {}
+ void findAndRenameLogFiles();
bool saveCrashBehaviorSetting(S32 crash_behavior);
bool sendCrashLogs();
LLSD constructPostData();