* Makes the crash log, writes it to a file and then subsequently tries * to make a crash dump and crash savegame. It uses DEBUG to write * information like paths to the console. */
| 270 | * information like paths to the console. |
| 271 | */ |
| 272 | void CrashLog::MakeCrashLog() |
| 273 | { |
| 274 | /* Don't keep looping logging crashes. */ |
| 275 | static bool crashlogged = false; |
| 276 | if (crashlogged) return; |
| 277 | crashlogged = true; |
| 278 | |
| 279 | fmt::print("Crash encountered, generating crash log...\n"); |
| 280 | this->FillCrashLog(); |
| 281 | fmt::print("Crash log generated.\n\n"); |
| 282 | |
| 283 | fmt::print("Crash in summary:\n"); |
| 284 | this->TryExecute("crashlog", [this]() { this->PrintCrashLog(); return true; }); |
| 285 | |
| 286 | fmt::print("Writing crash log to disk...\n"); |
| 287 | bool ret = this->TryExecute("crashlog", [this]() { return this->WriteCrashLog(); }); |
| 288 | if (ret) { |
| 289 | fmt::print("Crash log written to {}. Please add this file to any bug reports.\n\n", this->crashlog_filename); |
| 290 | } else { |
| 291 | fmt::print("Writing crash log failed. Please attach the output above to any bug reports.\n\n"); |
| 292 | this->crashlog_filename = "(failed to write crash log)"; |
| 293 | } |
| 294 | |
| 295 | fmt::print("Writing crash dump to disk...\n"); |
| 296 | ret = this->TryExecute("crashdump", [this]() { return this->WriteCrashDump(); }); |
| 297 | if (ret) { |
| 298 | fmt::print("Crash dump written to {}. Please add this file to any bug reports.\n\n", this->crashdump_filename); |
| 299 | } else { |
| 300 | fmt::print("Writing crash dump failed.\n\n"); |
| 301 | this->crashdump_filename = "(failed to write crash dump)"; |
| 302 | } |
| 303 | |
| 304 | fmt::print("Writing crash savegame...\n"); |
| 305 | ret = this->TryExecute("savegame", [this]() { return this->WriteSavegame(); }); |
| 306 | if (ret) { |
| 307 | fmt::print("Crash savegame written to {}. Please add this file and the last (auto)save to any bug reports.\n\n", this->savegame_filename); |
| 308 | } else { |
| 309 | fmt::print("Writing crash savegame failed. Please attach the last (auto)save to any bug reports.\n\n"); |
| 310 | this->savegame_filename = "(failed to write crash savegame)"; |
| 311 | } |
| 312 | |
| 313 | fmt::print("Writing crash screenshot...\n"); |
| 314 | ret = this->TryExecute("screenshot", [this]() { return this->WriteScreenshot(); }); |
| 315 | if (ret) { |
| 316 | fmt::print("Crash screenshot written to {}. Please add this file to any bug reports.\n\n", this->screenshot_filename); |
| 317 | } else { |
| 318 | fmt::print("Writing crash screenshot failed.\n\n"); |
| 319 | this->screenshot_filename = "(failed to write crash screenshot)"; |
| 320 | } |
| 321 | |
| 322 | this->TryExecute("survey", [this]() { this->SendSurvey(); return true; }); |
| 323 | } |
| 324 | |
| 325 | /** |
| 326 | * Sets a message for the error message handler. |
no test coverage detected