Crashlog: Suffix crash file names with date/time
This commit is contained in:
@@ -626,7 +626,7 @@ bool CrashLog::WriteScreenshot(char *filename, const char *filename_last, const
|
|||||||
* information like paths to the console.
|
* information like paths to the console.
|
||||||
* @return true when everything is made successfully.
|
* @return true when everything is made successfully.
|
||||||
*/
|
*/
|
||||||
bool CrashLog::MakeCrashLog() const
|
bool CrashLog::MakeCrashLog()
|
||||||
{
|
{
|
||||||
/* Don't keep looping logging crashes. */
|
/* Don't keep looping logging crashes. */
|
||||||
static bool crashlogged = false;
|
static bool crashlogged = false;
|
||||||
@@ -637,13 +637,17 @@ bool CrashLog::MakeCrashLog() const
|
|||||||
char buffer[65536 * 4];
|
char buffer[65536 * 4];
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
|
char *name_buffer_date = this->name_buffer + seprintf(this->name_buffer, lastof(this->name_buffer), "crash-");
|
||||||
|
time_t cur_time = time(nullptr);
|
||||||
|
strftime(name_buffer_date, lastof(this->name_buffer) - name_buffer_date, "%Y%m%dT%H%M%SZ", gmtime(&cur_time));
|
||||||
|
|
||||||
printf("Crash encountered, generating crash log...\n");
|
printf("Crash encountered, generating crash log...\n");
|
||||||
this->FillCrashLog(buffer, lastof(buffer));
|
this->FillCrashLog(buffer, lastof(buffer));
|
||||||
printf("%s\n", buffer);
|
printf("%s\n", buffer);
|
||||||
printf("Crash log generated.\n\n");
|
printf("Crash log generated.\n\n");
|
||||||
|
|
||||||
printf("Writing crash log to disk...\n");
|
printf("Writing crash log to disk...\n");
|
||||||
bool bret = this->WriteCrashLog(buffer, filename, lastof(filename));
|
bool bret = this->WriteCrashLog(buffer, filename, lastof(filename), this->name_buffer);
|
||||||
if (bret) {
|
if (bret) {
|
||||||
printf("Crash log written to %s. Please add this file to any bug reports.\n\n", filename);
|
printf("Crash log written to %s. Please add this file to any bug reports.\n\n", filename);
|
||||||
} else {
|
} else {
|
||||||
@@ -767,7 +771,7 @@ bool CrashLog::MakeCrashSavegameAndScreenshot() const
|
|||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
printf("Writing crash savegame...\n");
|
printf("Writing crash savegame...\n");
|
||||||
bool bret = this->WriteSavegame(filename, lastof(filename));
|
bool bret = this->WriteSavegame(filename, lastof(filename), this->name_buffer);
|
||||||
if (bret) {
|
if (bret) {
|
||||||
printf("Crash savegame written to %s. Please add this file and the last (auto)save to any bug reports.\n\n", filename);
|
printf("Crash savegame written to %s. Please add this file and the last (auto)save to any bug reports.\n\n", filename);
|
||||||
} else {
|
} else {
|
||||||
@@ -776,7 +780,7 @@ bool CrashLog::MakeCrashSavegameAndScreenshot() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Writing crash screenshot...\n");
|
printf("Writing crash screenshot...\n");
|
||||||
bret = this->WriteScreenshot(filename, lastof(filename));
|
bret = this->WriteScreenshot(filename, lastof(filename), this->name_buffer);
|
||||||
if (bret) {
|
if (bret) {
|
||||||
printf("Crash screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
|
printf("Crash screenshot written to %s. Please add this file to any bug reports.\n\n", filename);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -122,6 +122,9 @@ protected:
|
|||||||
char *LogCommandLog(char *buffer, const char *last) const;
|
char *LogCommandLog(char *buffer, const char *last) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** Buffer for the filename name prefix */
|
||||||
|
char name_buffer[64];
|
||||||
|
|
||||||
/** Stub destructor to silence some compilers. */
|
/** Stub destructor to silence some compilers. */
|
||||||
virtual ~CrashLog() {}
|
virtual ~CrashLog() {}
|
||||||
|
|
||||||
@@ -143,7 +146,7 @@ public:
|
|||||||
bool WriteSavegame(char *filename, const char *filename_last, const char *name = "crash") const;
|
bool WriteSavegame(char *filename, const char *filename_last, const char *name = "crash") const;
|
||||||
bool WriteScreenshot(char *filename, const char *filename_last, const char *name = "crash") const;
|
bool WriteScreenshot(char *filename, const char *filename_last, const char *name = "crash") const;
|
||||||
|
|
||||||
bool MakeCrashLog() const;
|
bool MakeCrashLog();
|
||||||
bool MakeDesyncCrashLog(const std::string *log_in, std::string *log_out, const DesyncExtraInfo &info) const;
|
bool MakeDesyncCrashLog(const std::string *log_in, std::string *log_out, const DesyncExtraInfo &info) const;
|
||||||
bool MakeVersionInfoLog() const;
|
bool MakeVersionInfoLog() const;
|
||||||
bool MakeCrashSavegameAndScreenshot() const;
|
bool MakeCrashSavegameAndScreenshot() const;
|
||||||
|
@@ -82,6 +82,7 @@ public:
|
|||||||
this->crashlog_filename[0] = '\0';
|
this->crashlog_filename[0] = '\0';
|
||||||
this->crashdump_filename[0] = '\0';
|
this->crashdump_filename[0] = '\0';
|
||||||
this->screenshot_filename[0] = '\0';
|
this->screenshot_filename[0] = '\0';
|
||||||
|
this->name_buffer[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -636,11 +637,14 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
|||||||
CrashLogWindows *log = new CrashLogWindows(ep);
|
CrashLogWindows *log = new CrashLogWindows(ep);
|
||||||
CrashLogWindows::current = log;
|
CrashLogWindows::current = log;
|
||||||
char *buf = log->FillCrashLog(log->crashlog, lastof(log->crashlog));
|
char *buf = log->FillCrashLog(log->crashlog, lastof(log->crashlog));
|
||||||
|
char *name_buffer_date = log->name_buffer + seprintf(log->name_buffer, lastof(log->name_buffer), "crash-");
|
||||||
|
time_t cur_time = time(nullptr);
|
||||||
|
strftime(name_buffer_date, lastof(log->name_buffer) - name_buffer_date, "%Y%m%dT%H%M%SZ", gmtime(&cur_time));
|
||||||
log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename));
|
log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename));
|
||||||
log->AppendDecodedStacktrace(buf, lastof(log->crashlog));
|
log->AppendDecodedStacktrace(buf, lastof(log->crashlog));
|
||||||
log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename));
|
log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename), log->name_buffer);
|
||||||
SetScreenshotAuxiliaryText("Crash Log", log->crashlog);
|
SetScreenshotAuxiliaryText("Crash Log", log->crashlog);
|
||||||
log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename));
|
log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename), log->name_buffer);
|
||||||
|
|
||||||
/* Close any possible log files */
|
/* Close any possible log files */
|
||||||
CloseConsoleLogIfActive();
|
CloseConsoleLogIfActive();
|
||||||
@@ -831,7 +835,7 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
_savegame_DBGL_data = CrashLogWindows::current->crashlog;
|
_savegame_DBGL_data = CrashLogWindows::current->crashlog;
|
||||||
_save_DBGC_data = true;
|
_save_DBGC_data = true;
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
if (CrashLogWindows::current->WriteSavegame(filename, lastof(filename))) {
|
if (CrashLogWindows::current->WriteSavegame(filename, lastof(filename), CrashLogWindows::current->name_buffer)) {
|
||||||
size_t len = _tcslen(_save_succeeded) + _tcslen(OTTD2FS(filename)) + 1;
|
size_t len = _tcslen(_save_succeeded) + _tcslen(OTTD2FS(filename)) + 1;
|
||||||
TCHAR *text = AllocaM(TCHAR, len);
|
TCHAR *text = AllocaM(TCHAR, len);
|
||||||
_sntprintf(text, len, _save_succeeded, OTTD2FS(filename));
|
_sntprintf(text, len, _save_succeeded, OTTD2FS(filename));
|
||||||
|
Reference in New Issue
Block a user