The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
log_windows.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Ignacio Riquelme Morelle <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef DESKTOP_WINDOWS_LOG_HPP_INCLUDED
16 #define DESKTOP_WINDOWS_LOG_HPP_INCLUDED
17 
18 #include <string>
19 
20 /**
21  * @file
22  * Log file control routines for Windows.
23  *
24  * During static object initialization, stdout and stderr are redirected to a
25  * uniquely-named log file located in the user's temporary directory as defined
26  * by the platform (e.g. C:/Users/username/AppData/Local/Temp/wesnoth-XXXX.log).
27  * Later, a request may be issued to relocate the log file to a more permanent
28  * and user-accessible location (such as the Wesnoth user data directory).
29  *
30  * Because Wesnoth is normally built with the GUI subsystem option, there is no
31  * console on startup and thus no way to see stdout/stderr output. Since
32  * version 1.13.1, we can allocate a console during initialization when started
33  * with the --wconsole option, but that is a somewhat clunky hack that does not
34  * help with post mortem debugging.
35  *
36  * SDL 1.2 used to redirect stdout and stderr to stdout.txt and stderr.txt in
37  * the process working directory automatically, but this approach too had its
38  * own shortcomings by assuming the pwd was writable by the process (or in Vista
39  * and later versions, requiring UAC virtualization to be enabled).
40  */
41 
42 namespace lg
43 {
44 
45 /**
46  * Returns the path to the current log file.
47  *
48  * An empty string is returned if the log file has not been set up yet or it
49  * was disabled (e.g. by --wconsole).
50  */
52 
53 /**
54  * Sets up the initial temporary log file.
55  *
56  * This has to be done on demand (preferably as early as possible) from a
57  * function rather than during static initialization, otherwise things go
58  * horribly wrong as soon as we try to use the logging facilities internally
59  * for debug messages.
60  */
62 
63 /**
64  * Relocates the stdout+stderr log file to the user data directory.
65  *
66  * This function exits the process if something goes wrong (including calling
67  * it when the user data directory isn't known yet).
68  */
70 
71 /**
72  * Switches to using a native console instead of log file redirection.
73  *
74  * In this mode, the log file is closed (if it was created in the first place)
75  * and output is sent directly to an attached or allocated console instead.
76  * This is used to implement the --wconsole command line option.
77  *
78  * Using a native console instead of a file has the benefit of allowing to see
79  * output in real time or redirecting it to a user-specified file.
80  */
82 
83 }
84 
85 #endif
std::string log_file_path()
Returns the path to the current log file.
void finish_log_file_setup()
Relocates the stdout+stderr log file to the user data directory.
void early_log_file_setup()
Sets up the initial temporary log file.
void enable_native_console_output()
Switches to using a native console instead of log file redirection.
Definition: pump.hpp:42
GLsizei const GLcharARB ** string
Definition: glew.h:4503