[Commits] [wesnoth/wesnoth] aae8e7: log/windows: Add our own stdout/stderr redirection...

GitHub noreply at github.com
Mon Nov 23 06:43:30 UTC 2015


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: aae8e70c7aff84117f48271dedbd1f2189fd7509
      https://github.com/wesnoth/wesnoth/commit/aae8e70c7aff84117f48271dedbd1f2189fd7509
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-11-23 (Mon, 23 Nov 2015)

  Changed paths:
    M projectfiles/CodeBlocks/wesnoth.cbp
    M projectfiles/CodeBlocks/wesnothd.cbp
    M src/CMakeLists.txt
    M src/SConscript
    M src/filesystem_boost.cpp
    A src/libc_error.hpp
    A src/log_windows.cpp
    A src/log_windows.hpp
    M src/wesnoth.cpp

  Log Message:
  -----------
  log/windows: Add our own stdout/stderr redirection on Windows

This replaces SDL 1.2's built-in stdout/stderr redirection, which writes
the log file to the process working directory (usually an
admin-restricted location) instead of a more accessible user-writable
location.

My approach combines stdout and stderr into a single log file which
includes the process id and timestamp in its filename in order to
accomodate multiple instances and (coming later) log rotation. The log
file is created in the user's temporary directory defined by Windows,
and then relocated to the game user data dir as soon as it is set-up the
first time, placed in the Windows-specific logs/ subdir.

The most pressing issues this solves are the lack of built-in
stdout/stderr redirection in SDL 2's SDL2main.lib entry point, and
Unicode path issues with SDL 1.2 (bug #22897). Additionally, it allows
us to not have to rely on UAC virtualization anymore; this is arguably
far more important because it has been known to break on occasion (e.g.
<http://r.wesnoth.org/t42970>), and starting with version 1.13.2 we want
to declare Windows Vista - 10 compatibility in our side-by-side manifest
(see commit e119f4071f047c6d740ebec4636985fdf39349bc).

Currently missing features coming later:

 * Log rotation (otherwise the logs/ dir may grow forever)
 * wesnothd support (although the code is already required to be linked
   into wesnothd due to it being required by the FS API)
 * Integration with the version info dialog


  Commit: 900dc5b07017bfcf6ea08fc06a09a5f1cfb712db
      https://github.com/wesnoth/wesnoth/commit/900dc5b07017bfcf6ea08fc06a09a5f1cfb712db
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-11-23 (Mon, 23 Nov 2015)

  Changed paths:
    M src/log_windows.cpp

  Log Message:
  -----------
  log/windows: Implement log file rotation

A maximum of 8 previous log files are kept around in the logs directory.
Older files are automatically deleted during initialization.

I could've achieved this with stat calls, really, but the log filenames
are simpler and faster to process.


  Commit: bc9fb0c1110027b7fddaf7860cd0fded652e91a2
      https://github.com/wesnoth/wesnoth/commit/bc9fb0c1110027b7fddaf7860cd0fded652e91a2
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-11-23 (Mon, 23 Nov 2015)

  Changed paths:
    M src/log_windows.cpp

  Log Message:
  -----------
  log/windows: Close stdout and stderr on destruction if redirected

No real reason to do this since these resources should be automatically
released on process exit anyway, but, better safe than sorry I guess.


  Commit: 53ed94da251b231a41e399bcee634be3fa813343
      https://github.com/wesnoth/wesnoth/commit/53ed94da251b231a41e399bcee634be3fa813343
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-11-23 (Mon, 23 Nov 2015)

  Changed paths:
    M projectfiles/CodeBlocks/wesnoth.cbp
    M src/CMakeLists.txt
    M src/SConscript
    R src/desktop/windows_console.cpp
    R src/desktop/windows_console.hpp
    M src/gui/dialogs/game_version.cpp
    M src/log_windows.cpp
    M src/log_windows.hpp
    M src/wesnoth.cpp

  Log Message:
  -----------
  log/windows: Integrate implementation of --wconsole

This makes it so we no longer try to steal the console back to a log
file when using --wconsole with the new redirection code. Now the
--wconsole switch triggers a special mode of the log file manager that
uses a native console instead of log files.

As a necessary bonus to appease compilers, the GUI2 version info dialog
now uses the correct log file path when not started with the --wconsole
switch. Yay!


  Commit: baae0bd708d3b61ff0440a4b4d22519c230a0c32
      https://github.com/wesnoth/wesnoth/commit/baae0bd708d3b61ff0440a4b4d22519c230a0c32
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-11-23 (Mon, 23 Nov 2015)

  Changed paths:
    M src/log_windows.cpp

  Log Message:
  -----------
  log/windows: Auto-disable log file if a console is attached at startup

This change only actually concerns binaries built with the console
subsystem flag, which isn't the case with our official project files or
SCons recipe.


  Commit: 758f929a7bca73c9272746292b1367b4945654c2
      https://github.com/wesnoth/wesnoth/commit/758f929a7bca73c9272746292b1367b4945654c2
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-11-23 (Mon, 23 Nov 2015)

  Changed paths:
    M RELEASE_NOTES
    M changelog

  Log Message:
  -----------
  Update changelog and RELEASE_NOTES


  Commit: 71009d939f37e5ea3900c1aa23affc404c30ffa1
      https://github.com/wesnoth/wesnoth/commit/71009d939f37e5ea3900c1aa23affc404c30ffa1
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-11-23 (Mon, 23 Nov 2015)

  Changed paths:
    M RELEASE_NOTES
    M changelog
    M projectfiles/CodeBlocks/wesnoth.cbp
    M projectfiles/CodeBlocks/wesnothd.cbp
    M src/CMakeLists.txt
    M src/SConscript
    R src/desktop/windows_console.cpp
    R src/desktop/windows_console.hpp
    M src/filesystem_boost.cpp
    M src/gui/dialogs/game_version.cpp
    A src/libc_error.hpp
    A src/log_windows.cpp
    A src/log_windows.hpp
    M src/wesnoth.cpp

  Log Message:
  -----------
  Merge branch 'feature/win32-stdio-redir'


Compare: https://github.com/wesnoth/wesnoth/compare/a7bb6b1fa57f...71009d939f37


More information about the Commits mailing list