mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Win32: add the --win32log option to log stdout and stderr to files
Adding --win32log as the first command line option on Windows will now log all stdout and stderr output to the files subsurface_err.log and subsurface_out.log in the working directory. This change required a new argument 'bool logfile' to be added to: subsurface_console_init() which is defined in all platform files (linux.c, macos.c, etc.) Example usage: subsurface.exe --win32log -v -v -v Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
7c8461a328
commit
4a894e0713
7 changed files with 29 additions and 12 deletions
|
@ -377,11 +377,12 @@ static struct {
|
|||
FILE *out, *err;
|
||||
} console_desc;
|
||||
|
||||
void subsurface_console_init(bool dedicated)
|
||||
void subsurface_console_init(bool dedicated, bool logfile)
|
||||
{
|
||||
(void)console_desc;
|
||||
/* if this is a console app already, do nothing */
|
||||
#ifndef WIN32_CONSOLE_APP
|
||||
|
||||
/* just in case of multiple calls */
|
||||
memset((void *)&console_desc, 0, sizeof(console_desc));
|
||||
/* the AttachConsole(..) call can be used to determine if the parent process
|
||||
|
@ -421,9 +422,12 @@ void subsurface_console_init(bool dedicated)
|
|||
SetConsoleCtrlHandler(NULL, TRUE); /* disable the CTRL handler */
|
||||
}
|
||||
|
||||
const char *location_out = logfile ? "subsurface_out.log" : "CON";
|
||||
const char *location_err = logfile ? "subsurface_err.log" : "CON";
|
||||
|
||||
/* redirect; on win32, CON is a reserved pipe target, like NUL */
|
||||
console_desc.out = freopen("CON", "w", stdout);
|
||||
console_desc.err = freopen("CON", "w", stderr);
|
||||
console_desc.out = freopen(location_out, "w", stdout);
|
||||
console_desc.err = freopen(location_err, "w", stderr);
|
||||
if (!dedicated)
|
||||
puts(""); /* add an empty line */
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue