Add an environment variable to disable logging to file

Fixes #8527
This commit is contained in:
pentarctagon 2024-03-16 13:15:51 -05:00 committed by Pentarctagon
parent 2265127b66
commit c00cfe2a05
3 changed files with 3 additions and 3 deletions

View file

@ -191,7 +191,7 @@ lists defined log domains (only the ones containing
if used) and exits
.TP
.B --no-log-to-file
prevents redirecting logged output to a file. Log files are created in the logs directory under the userdata folder.
prevents redirecting logged output to a file. The environment variable WESNOTH_NO_LOG_FILE can also be set as an alternative. Log files are created in the logs directory under the userdata folder.
.TP
.B --log-to-file
log output is written to a file. Cancels the effect of --no-log-to-file whether implicit or explicit.

View file

@ -251,7 +251,7 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
("log-debug", po::value<std::vector<std::string>>()->composing(), "sets the severity level of the specified log domain(s) to 'debug'. Similar to --log-error.")
("log-none", po::value<std::vector<std::string>>()->composing(), "sets the severity level of the specified log domain(s) to 'none'. Similar to --log-error.")
("log-precise", "shows the timestamps in log output with more precision.")
("no-log-to-file", "log output is written only to standard error rather than to a file.")
("no-log-to-file", "log output is written only to standard error rather than to a file. The environment variable WESNOTH_NO_LOG_FILE can also be set as an alternative.")
("log-to-file", "log output is written to a file. Cancels the effect of --no-log-to-file whether implicit or explicit.")
("wnoconsole", "For Windows, when used with --no-log-to-file, results in output being written to cerr/cout instead of CONOUT. Otherwise, does nothing.")
;

View file

@ -1041,7 +1041,7 @@ int main(int argc, char** argv)
// write_to_log_file means that writing to the log file will be done, if true.
// if false, output will be written to the terminal
// on windows, if wesnoth was not started from a console, then it will allocate one
bool write_to_log_file = true;
bool write_to_log_file = !getenv("WESNOTH_NO_LOG_FILE");
[[maybe_unused]]
bool no_con = false;