For non-Windows platforms this adds:
* a new check for whether the logs directory exists and is writable by attempting to write a single whitespace to a dummy.log file.
* a popup shown immediately after the GUI system is initialized letting the player know if there was an issue creating the log file.
For Windows, this changes:
* instead of writing to the OS temp directory and then attempting to move that file to the logs directory, this uses the same check that was described above for non-Windows platforms.
* the alert shown when writing the dummy log file fails is now a Wesnoth alert message rather than the Windows-specific MessageBox.
* a failure to create a log file does not immediately exit wesnoth anymore.
Additionally, this makes it so that for the default state (logging to file), all platforms follow the same code path by calling `lg::set_log_to_file()`. `log_windows` now contains only the Windows-specific logic needed for handling the creation/redirection of output to a console.
These include an alternate mode of normalize_path() that enforces the
platform's preferred path delimiter (i.e. backslash on Windows) on the
output, and a function to detect whether a path refers to a root
directory.
Unfortunately, the last bit requires introducing a new link-time
dependency on Windows, against a system library. It's guaranteed to be
always there but it seems kind of a waste. The alternative would be to
hand-parse the string but that seems even more of a waste. And no,
Boost.Filesystem can't do this in a straightforward fashion right now.
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 e119f4071f).
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