redirecting debug output to a file on Windows

Lubomir I. Ivanov neolit123 at gmail.com
Thu Feb 2 11:51:47 PST 2017


On 2 February 2017 at 21:35, Dirk Hohndel <dirk at hohndel.org> wrote:
> On Thu, Feb 02, 2017 at 09:33:32PM +0200, Lubomir I. Ivanov wrote:
>> On 2 February 2017 at 21:12, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
>> >  const char *location = logfile ? "subsurface.log" : "CON";
>> >
>> > console_desc.out = freopen(location, "w", stdout);
>> > console_desc.err = freopen(location, "w", stderr);
>>
>> ^ this *probably* won't work for stderr, though.
>
> That sucks as the debug output all goes to stderr :-(
>

attached is updated patch to write separate output files:
subsurface_err.log
subsurface_out.log

using something like:
dup2(fileno(stdout), fileno(stderr));

to redirect stderr to stdout doesn't seem to work on windows, and even
if it does it will probably have buffer sync issues.

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.

lubomir
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Win32-add-the-win32log-option-to-log-stdout-and-stde.patch
Type: text/x-patch
Size: 6040 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20170202/bdac8172/attachment.bin>


More information about the subsurface mailing list