The Battle for Wesnoth  1.15.1+dev
Namespaces | Functions
log_windows.hpp File Reference

Log file control routines for Windows. More...

#include <string>
Include dependency graph for log_windows.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 lg
 

Functions

std::string lg::log_file_path ()
 Returns the path to the current log file. More...
 
void lg::early_log_file_setup ()
 Sets up the initial temporary log file. More...
 
void lg::finish_log_file_setup ()
 Relocates the stdout+stderr log file to the user data directory. More...
 
void lg::enable_native_console_output ()
 Switches to using a native console instead of log file redirection. More...
 
bool lg::using_own_console ()
 Returns true if a console was allocated by the Wesnoth process. More...
 

Detailed Description

Log file control routines for Windows.

During static object initialization, stdout and stderr are redirected to a uniquely-named log file located in the user's temporary directory as defined by the platform (e.g. C:/Users/username/AppData/Local/Temp/wesnoth-XXXX.log). Later, a request may be issued to relocate the log file to a more permanent and user-accessible location (such as the Wesnoth user data directory).

Because Wesnoth is normally built with the GUI subsystem option, there is no console on startup and thus no way to see stdout/stderr output. Since version 1.13.1, we can allocate a console during initialization when started with the –wconsole option, but that is a somewhat clunky hack that does not help with post mortem debugging.

SDL 1.2 used to redirect stdout and stderr to stdout.txt and stderr.txt in the process working directory automatically, but this approach too had its own shortcomings by assuming the pwd was writable by the process (or in Vista and later versions, requiring UAC virtualization to be enabled).

Definition in file log_windows.hpp.