windows, saving the output to a log file

Tomaz Canabrava tcanabrava at kde.org
Fri Nov 3 02:22:37 PDT 2017


On Fri, Nov 3, 2017 at 1:03 AM, Lubomir I. Ivanov <neolit123 at gmail.com>
wrote:

> 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.
>

Probably.
in the case of qDebugs / qCDebugs we can create a function to intercept the
calls and write the logs, I'm unsure about printf.
I think Qt does the same as you did in the code example, so it also
redirects to somewhere.

the code to intercept the qDebug calls already exist on mobile builds, if I
remember correctly.
look for installMessageHandler

Tomaz


> lubomir
> --
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171103/b49fb4c2/attachment.html>


More information about the subsurface mailing list