Log desync debug output to the console as well as the file.

Be fault tolerant if the desync and/or random file cannot be created,
and write to the console.
This commit is contained in:
Jonathan G Rennison
2015-09-27 15:09:11 +01:00
parent 106c44ac48
commit 60d15aa755

View File

@@ -122,19 +122,21 @@ static void debug_print(const char *dbg, const char *buf)
#endif /* ENABLE_NETWORK */
if (strcmp(dbg, "desync") == 0) {
static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
if (f == NULL) return;
if (f != NULL) {
fprintf(f, "%s%s\n", GetLogPrefix(), buf);
fflush(f);
}
#ifdef RANDOM_DEBUG
} else if (strcmp(dbg, "random") == 0) {
static FILE *f = FioFOpenFile("random-out.log", "wb", AUTOSAVE_DIR);
if (f == NULL) return;
if (f != NULL) {
fprintf(f, "%s\n", buf);
fflush(f);
return;
}
#endif
} else {
}
char buffer[512];
seprintf(buffer, lastof(buffer), "%sdbg: [%s] %s\n", GetLogPrefix(), dbg, buf);
#if defined(WINCE)
@@ -148,7 +150,6 @@ static void debug_print(const char *dbg, const char *buf)
NetworkAdminConsole(dbg, buf);
#endif /* ENABLE_NETWORK */
IConsoleDebug(dbg, buf);
}
}
/**