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