ENH: rename tracked crash log

Change-Id: I60d1c1af873c60776334f26503e22230bb541e0a
This commit is contained in:
liz.li 2023-04-03 16:53:10 +08:00 committed by Lane.Wei
parent fddd101685
commit 02fbd88150
1 changed files with 19 additions and 15 deletions

View File

@ -1141,22 +1141,26 @@ void GUI_App::post_init()
{
std::string file_name = iter->path().stem().string();
if (boost::starts_with(file_name, "crash")) {
std::ifstream ifs(iter->path().string(), ios::in);
std::stringstream data;
data << ifs.rdbuf();
ifs.close();
if (file_name.find("done") == std::string::npos) {
std::ifstream ifs(iter->path().string(), ios::in);
std::stringstream data;
data << ifs.rdbuf();
ifs.close();
NetworkAgent* agent = wxGetApp().getAgent();
json j;
j["time"] = file_name.substr(file_name.find("crash") + strlen("crash") + 1);
j["verion"] = std::string(SLIC3R_VERSION);
j["content"] = decode_path(data.str().c_str());
try {
if (agent) {
agent->track_event("studio_crash", j.dump()); }
} catch (...) {}
std::string new_file_name = file_name.insert(0, "_done_");
boost::filesystem::rename(iter->path(), iter->path().parent_path() / boost::filesystem::path(new_file_name + iter->path().extension().string()));
NetworkAgent* agent = wxGetApp().getAgent();
json j;
j["time"] = file_name.substr(file_name.find("crash") + strlen("crash") + 1);
j["verion"] = std::string(SLIC3R_VERSION);
j["content"] = decode_path(data.str().c_str());
try {
if (agent) {
agent->track_event("studio_crash", j.dump());
}
}
catch (...) {}
std::string new_file_name = file_name.append("_done");
boost::filesystem::rename(iter->path(), iter->path().parent_path() / boost::filesystem::path(new_file_name + iter->path().extension().string()));
}
}
}
}