redirecting debug output to a file on Windows

Dirk Hohndel dirk at hohndel.org
Thu Feb 2 11:34:18 PST 2017


On Thu, Feb 02, 2017 at 09:12:19PM +0200, Lubomir I. Ivanov wrote:
> On 2 February 2017 at 18:37, Dirk Hohndel <dirk at hohndel.org> wrote:
> > Lubomir (and others)
> >
> > I know this used to work, but somehow it doesn't any more...
> >
> > subsurface.exe 1> dbg.txt 2>&1
> >
> > instead this prints to stdout and dbg.txt stays completely empty.
> >
> > Any idea how I can get it to do what I want to do (i.e., collect all
> > output in a file)?
> >
> 
> the command line redirection (>) isn't working and i don't know why. i
> wonder if it ever worked.

I am 96.2% certain that it did because I remember us adding the
--win32console option for that... look at this commit message :-)

commit 74ed786d7546b22ec31fbd441a7a03b7b06836a4
Author: Lubomir I. Ivanov <neolit123 at gmail.com>
Date:   Tue Mar 25 16:55:56 2014 +0200

    Add optional Win32 console allocation
    
    This patch adds the optional --win32console command line option.
    It does nothing on OSx and Linux, while is only useable on Win32.
    
    On Win32 if the application was built as GUI (not console),
    there is no way to view stdout and stderr. With windows.c's
    subsurface_console_init() we are able to either redirect
    stdout and stderr to the terminal from which subsurface.exe
    was started (always happens; --win32console does nothing in
    this case) or if --win32console is explicitly added to
    a shortcut, create a dedicated console window and monitor
    the output there.
    
> tried like 5 different solutions, to no avail.
> 
> alternative solution / patch attached.
> 
> what it does:
> - uses a new win32 specific command line argument --win32log
> - the freopen() call in windows.c::subsurface_console_init() now knows
> if we want to log the output to a file or to the CON (console)
> "device"
> - eventually it can both output to the console and write to a file
> 
> you can apply it and use like so:
> cd <subsurface-path>
> subsurface.exe --win32log -v -v -v
> 
> a file subsurface.log will be written.

I can use that for this particular experiment - I'd love a more generic
solution, though (yeah, I know, it's not nice to ask for things you have
no idea how to do...)

Thanks, Lubomir!

/D


More information about the subsurface mailing list