mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-06-11 13:29:30 +00:00
implemented issue #7: output stdout and stderr to a log file; removed output redirection to win32 console, which was buggy
This commit is contained in:
parent
6abc599ddf
commit
109bc3979b
|
@ -212,12 +212,25 @@ int main(int argc, char **argv)
|
||||||
char str[256];
|
char str[256];
|
||||||
bool cd_boot = false;
|
bool cd_boot = false;
|
||||||
|
|
||||||
// Make sure stdout and stderr gets displayed, if and when the app is run
|
// Redirect stdout and stderr to a log file, for diagnostic purposes.
|
||||||
// via a command prompt window.
|
// Unbuffered file IO will be used (setup via setvbuf() calls), so as
|
||||||
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
|
// to write log file data ASAP, lest it get lost in case of program
|
||||||
freopen("CONOUT$", "w", stdout);
|
// termination.
|
||||||
freopen("CONOUT$", "w", stderr);
|
wchar_t logFileName[4096];
|
||||||
}
|
logFileName[0] = L'\0';
|
||||||
|
_wgetcwd(logFileName, SDL_arraysize(logFileName));
|
||||||
|
if (logFileName[0] != L'\0') {
|
||||||
|
SDL_wcslcat(logFileName, L"\\BasiliskII_log.txt", SDL_arraysize(logFileName));
|
||||||
|
FILE * fp;
|
||||||
|
fp = _wfreopen(logFileName, L"w", stdout);
|
||||||
|
if (fp) {
|
||||||
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
}
|
||||||
|
fp = _wfreopen(logFileName, L"w", stderr);
|
||||||
|
if (fp) {
|
||||||
|
setvbuf(stderr, NULL, _IONBF, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize variables
|
// Initialize variables
|
||||||
RAMBaseHost = NULL;
|
RAMBaseHost = NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user