| 90 | } |
| 91 | |
| 92 | std::filesystem::path get_crashlog_path() { |
| 93 | std::time_t time = std::time(nullptr); |
| 94 | std::tm* tm = std::localtime(&time); |
| 95 | |
| 96 | std::string timestamp = "unknown"; |
| 97 | if (tm) { |
| 98 | char stamp[64]; |
| 99 | std::size_t out = strftime(&stamp[0], 63, "%Y-%m-%d-%H-%M-%S", tm); |
| 100 | if (out != 0) |
| 101 | timestamp = stamp; |
| 102 | } |
| 103 | |
| 104 | std::filesystem::path dir = "crashlog"; |
| 105 | std::error_code err; |
| 106 | std::filesystem::create_directories(dir, err); |
| 107 | |
| 108 | std::filesystem::path log_path = dir / ("crash_" + timestamp + ".txt"); |
| 109 | return log_path; |
| 110 | } |
| 111 | |
| 112 | void dfhack_save_crashlog() { |
| 113 | char** backtrace_strings = backtrace_symbols(crash_info.backtrace, crash_info.backtrace_entries); |
no outgoing calls
no test coverage detected