Changeset 4a894e0 in subsurface


Ignore:
Timestamp:
Feb 3, 2017, 9:24:42 AM (2 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
a959e43
Parents:
7c8461a
git-author:
Lubomir I. Ivanov <neolit123@…> (02/02/17 11:50:47)
git-committer:
Dirk Hohndel <dirk@…> (02/03/17 09:24:42)
Message:

Win32: add the --win32log option to log stdout and stderr to files

Adding --win32log as the first command line option on Windows
will now log all stdout and stderr output to the files
subsurface_err.log and subsurface_out.log in the working directory.

This change required a new argument 'bool logfile' to be added to:
subsurface_console_init() which is defined in all platform files
(linux.c, macos.c, etc.)

Example usage:
subsurface.exe --win32log -v -v -v

Signed-off-by: Lubomir I. Ivanov <neolit123@…>

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • core/android.cpp

    r38474f2 r4a894e0  
    188188
    189189/* win32 console */
    190 void subsurface_console_init(bool dedicated)
    191 {
     190void subsurface_console_init(bool dedicated, bool logfile)
     191{
     192        (void)dedicated;
     193        (void)logifle;
    192194        /* NOP */
    193195}
  • core/dive.h

    r08c4281 r4a894e0  
    731731extern struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp);
    732732extern int subsurface_zip_close(struct zip *zip);
    733 extern void subsurface_console_init(bool dedicated);
     733extern void subsurface_console_init(bool dedicated, bool logfile);
    734734extern void subsurface_console_exit(void);
    735735extern bool subsurface_user_is_root(void);
  • core/linux.c

    r7be962b r4a894e0  
    216216
    217217/* win32 console */
    218 void subsurface_console_init(bool dedicated)
     218void subsurface_console_init(bool dedicated, bool logfile)
    219219{
    220220        (void)dedicated;
     221        (void)logifle;
    221222        /* NOP */
    222223}
  • core/macos.c

    r7be962b r4a894e0  
    202202
    203203/* win32 console */
    204 void subsurface_console_init(bool dedicated)
    205 {
    206         (void) dedicated;
     204void subsurface_console_init(bool dedicated, bool logfile)
     205{
     206        (void)dedicated;
     207        (void)logifle;
    207208        /* NOP */
    208209}
  • core/subsurfacestartup.c

    raaa46c2 r4a894e0  
    188188        printf("\n --user=<test>         Choose configuration space for user <test>");
    189189        printf("\n --cloud-timeout=<nr>  Set timeout for cloud connection (0 < timeout < 60)");
    190         printf("\n --win32console        Create a dedicated console if needed (Windows only). Add option before everything else\n\n");
     190        printf("\n --win32console        Create a dedicated console if needed (Windows only). Add option before everything else");
     191        printf("\n --win32log            Write the program output to subsurface.log (Windows only). Add option before everything else\n\n");
    191192}
    192193
     
    245246                        }
    246247                        if (strcmp(arg, "--win32console") == 0)
     248                                return;
     249                        if (strcmp(arg, "--win32log") == 0)
    247250                                return;
    248251                /* fallthrough */
  • core/windows.c

    r7be962b r4a894e0  
    378378} console_desc;
    379379
    380 void subsurface_console_init(bool dedicated)
     380void subsurface_console_init(bool dedicated, bool logfile)
    381381{
    382382        (void)console_desc;
    383383        /* if this is a console app already, do nothing */
    384384#ifndef WIN32_CONSOLE_APP
     385
    385386        /* just in case of multiple calls */
    386387        memset((void *)&console_desc, 0, sizeof(console_desc));
     
    422423        }
    423424
     425        const char *location_out = logfile ? "subsurface_out.log" : "CON";
     426        const char *location_err = logfile ? "subsurface_err.log" : "CON";
     427
    424428        /* redirect; on win32, CON is a reserved pipe target, like NUL */
    425         console_desc.out = freopen("CON", "w", stdout);
    426         console_desc.err = freopen("CON", "w", stderr);
     429        console_desc.out = freopen(location_out, "w", stdout);
     430        console_desc.err = freopen(location_err, "w", stderr);
    427431        if (!dedicated)
    428432                puts(""); /* add an empty line */
  • subsurface-desktop-main.cpp

    r8f35b73 r4a894e0  
    3535        QStringList arguments = QCoreApplication::arguments();
    3636
    37         bool dedicated_console = arguments.length() > 1 &&
    38                                  (arguments.at(1) == QString("--win32console"));
    39         subsurface_console_init(dedicated_console);
     37        bool win32_log = arguments.length() > 1 &&
     38                (arguments.at(1) == QString("--win32log"));
     39        if (win32_log) {
     40                subsurface_console_init(true, true);
     41        } else {
     42                bool dedicated_console = arguments.length() > 1 &&
     43                        (arguments.at(1) == QString("--win32console"));
     44                subsurface_console_init(dedicated_console, false);
     45        }
    4046
    4147        const char *default_directory = system_default_directory();
Note: See TracChangeset for help on using the changeset viewer.