On 2 February 2017 at 21:56, Dirk Hohndel <[email protected]> wrote: > On Thu, Feb 02, 2017 at 09:51:47PM +0200, Lubomir I. Ivanov wrote: >> >> attached is updated patch to write separate output files: >> subsurface_err.log >> subsurface_out.log > > Good enough for the use case. > >> the real, clean solution, of course is to redirect from the CMD line, >> but i have no idea why it no longer works. >> i'm pretty sure that i've tried that and it worked when i wrote the >> custom console code for windows. > > As I said, I am quite certain that this used to work. > I love it when things stop working and no one knows why. >
ok, so i've created a standalone test case and it appears that this type of redirection never worked. that's because the application EXE is a GUI application (-mwindows) and even if we redirect text to some console (via AttachConsole()), we cannot redirect the output of the executable call to a file, like so: gui_windows_test.exe > test.log because the GUI executable itself has no output, if that makes sense. *nix has that, but Windows doesn't. solutions: 1) my last patch...it writes separate log files for stderr / stdout it can write the output to the same file with this (mod in windows.c::subsurface_console_init()): const char *location = logfile ? "subsurface.log" : "CON"; console_desc.out = freopen(location, "w", stdout); *stderr = *stdout; // seems safe setvbuf(stderr, NULL, _IONBF, 0); // disable buffering setvbuf(stdout, NULL, _IONBF, 0); 2) create a windows console application stderr / stdout redirection of a windows console application will work for sure. also define WIN32_CONSOLE_APP (-DWIN32_CONSOLE_APP) QMAKE had this: CONFIG += console for CMAKE: http://stackoverflow.com/questions/2753761/how-do-i-tell-cmake-not-to-create-a-console-window lubomir -- _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
