windows, saving the output to a log file

Lubomir I. Ivanov neolit123 at gmail.com
Thu Nov 2 17:03:26 PDT 2017


On 2 November 2017 at 22:39, Dirk Hohndel <dirk at hohndel.org> wrote:
> Sorry, from memory / on my phone. If the app is a console app, the code to redirect is never executed. So for the apps we ship, I believe this doesn't work. At least it didn't when I tried last week. Error could of course be mine... Look at the code... The redirect is inside an if clause and we never got to that code...
>

https://github.com/Subsurface-divelog/subsurface/pull/763

i wasn't able to write to a single log file, thus we still have the
separate _err.log and _out.log files on win32.
spent 1.5 hours on this alone.

for a standalone C app this works:
-----------------------------------
int logfile = open("subsurface.log", O_CREAT | O_WRONLY); // tried
with S_IREAD | S_IWRITE too for p.bits.
close(STDOUT_FILENO);
close(STDERR_FILENO);
dup2(logfile, STDOUT_FILENO);
dup2(logfile, STDERR_FILENO);
setbuf(stdout, NULL);
setbuf(stderr, NULL);

// from this point on, stdout and stderr are both written to the .log file
-----------------------------------

in the case of subsurface, the log file is created, with OK
permissions, but remains empty.
maybe Qt is doing something to prevent this - no idea.

lubomir
--


More information about the subsurface mailing list