bool LLCrashLogger::sendCrashLogs() { gatherFiles(); LLSD post_data; post_data = constructPostData(); updateApplication("Sending reports..."); std::string dump_path = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLifeCrashReport"); std::string report_file = dump_path + ".log"; std::ofstream out_file(report_file.c_str()); LLSDSerialize::toPrettyXML(post_data, out_file); out_file.close(); bool sent = false; //*TODO: Translate if(mCrashHost != "") { sent = runCrashLogPost(mCrashHost, post_data, std::string("Sending to server"), 3, 5); } if(!sent) { sent = runCrashLogPost(mAltCrashHost, post_data, std::string("Sending to alternate server"), 3, 5); } mSentCrashLogs = sent; return true; }
static void updateAll(EditorWidget *my_widget){ foreach (QWidget *widget, QApplication::allWidgets()) updateWidget(my_widget, widget); //updateAll(my_widget,application->mainWidget()); updateApplication(my_widget,application); }
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); LLHTTPClient::post(host, data, new LLCrashLoggerResponder(), timeout); while(!gBreak) { updateApplication(status_message); } if(gSent) { return gSent; } } return gSent; }
void setApplicationColors(QApplication *app){ EditorWidget *my_widget = root==NULL ? NULL : root->song==NULL ? NULL : static_cast<EditorWidget*>(root->song->tracker_windows->os_visual.widget); override_default_qt_colors = SETTINGS_read_bool("override_default_qt_colors",true); #if 1 static bool first_run = true; if(first_run==true){ sys_palette = QApplication::palette(); SETTINGS_write_bool("override_default_qt_colors",override_default_qt_colors); first_run=false; } #endif printf("here\n"); application = app; if(my_widget==NULL) updateApplication(my_widget,app); else updateAll(my_widget); }
void LLCrashLoggerMac::gatherPlatformSpecificFiles() { updateApplication("Gathering hardware information..."); char path[MAX_PATH]; FSRef folder; if(FSFindFolder(kUserDomain, kLogsFolderType, false, &folder) == noErr) { // folder is an FSRef to ~/Library/Logs/ if(FSRefMakePath(&folder, (UInt8*)&path, sizeof(path)) == noErr) { struct stat dw_stat; std::string mBuf; bool isLeopard = false; // Try the 10.3 path first... std::string dw_file_name = std::string(path) + std::string("/CrashReporter/Second Life.crash.log"); int res = stat(dw_file_name.c_str(), &dw_stat); if (res) { // Try the 10.2 one next... dw_file_name = std::string(path) + std::string("/Second Life.crash.log"); res = stat(dw_file_name.c_str(), &dw_stat); } if(res) { //10.5: Like 10.3+, except it puts the crash time in the file instead of dividing it up //using asterisks. Get a directory listing, search for files starting with second life, //use the last one found. std::string old_file_name, current_file_name, pathname, mask; pathname = std::string(path) + std::string("/CrashReporter/"); mask = "Second Life*"; while(gDirUtilp->getNextFileInDir(pathname, mask, current_file_name, false)) { old_file_name = current_file_name; } if(old_file_name != "") { dw_file_name = pathname + old_file_name; res=stat(dw_file_name.c_str(), &dw_stat); isLeopard = true; } } if (!res) { std::ifstream fp(dw_file_name.c_str()); std::stringstream str; if(!fp.is_open()) return; str << fp.rdbuf(); mBuf = str.str(); if(!isLeopard) { // Crash logs consist of a number of entries, one per crash. // Each entry is preceeded by "**********" on a line by itself. // We want only the most recent (i.e. last) one. const char *sep = "**********"; const char *start = mBuf.c_str(); const char *cur = start; const char *temp = strstr(cur, sep); while(temp != NULL) { // Skip past the marker we just found cur = temp + strlen(sep); /* Flawfinder: ignore */ // and try to find another temp = strstr(cur, sep); } // If there's more than one entry in the log file, strip all but the last one. if(cur != start) { mBuf.erase(0, cur - start); } } mCrashInfo["CrashLog"] = mBuf; } else { llwarns << "Couldn't find any CrashReporter files..." << llendl; } } } }
void LLCrashLogger::gatherFiles() { /* //TODO:This function needs to be reimplemented somewhere in here... if(!previous_crash && is_crash_log) { // Make sure the file isn't too old. double age = difftime(gLaunchTime, stat_data.st_mtimespec.tv_sec); // llinfos << "age is " << age << llendl; if(age > 60.0) { // The file was last modified more than 60 seconds before the crash reporter was launched. Assume it's stale. llwarns << "File " << mFilename << " is too old!" << llendl; return; } } */ updateApplication("Gathering logs..."); // Figure out the filename of the debug log std::string db_file_name = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"debug_info.log"); 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); 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; } 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"); } gatherPlatformSpecificFiles(); //Use the debug log to reconstruct the URL to send the crash report to if(mDebugLog.has("CurrentSimHost")) { mCrashHost = "https://"; mCrashHost += mDebugLog["CurrentSimHost"].asString(); mCrashHost += ":12043/crash/report"; } else if(mDebugLog.has("GridName")) { // This is a 'little' hacky, but its the best simple solution. std::string grid_host = mDebugLog["GridName"].asString(); LLStringUtil::toLower(grid_host); mCrashHost = "https://login."; mCrashHost += grid_host; mCrashHost += ".lindenlab.com:12043/crash/report"; } // Use login servers as the alternate, since they are already load balanced and have a known name mAltCrashHost = "https://login.agni.lindenlab.com:12043/crash/report"; mCrashInfo["DebugLog"] = mDebugLog; mFileMap["StatsLog"] = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stats.log"); mFileMap["StackTrace"] = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); updateApplication("Encoding files..."); for(std::map<std::string, std::string>::iterator itr = mFileMap.begin(); itr != mFileMap.end(); ++itr) { std::ifstream f((*itr).second.c_str()); if(!f.is_open()) { std::cout << "Can't find file " << (*itr).second << std::endl; continue; } std::stringstream s; s << f.rdbuf(); std::string crash_info = s.str(); if(itr->first == "SecondLifeLog") { trimSLLog(crash_info); } mCrashInfo[(*itr).first] = crash_info; } }
static void updateAll(EditorWidget *my_widget){ updateAll(my_widget,application->mainWidget()); updateApplication(my_widget,application); }