Enable logging to file by default.

This commit is contained in:
Pentarctagon 2023-01-12 11:02:45 -06:00 committed by Steve Cotton
parent 7ca149ef78
commit ceb05f3d9f
4 changed files with 12 additions and 8 deletions

View file

@ -190,8 +190,8 @@ lists defined log domains (only the ones containing
.I filter
if used) and exits
.TP
.B --log-to-file
redirects logged output to a file. Log files are created in the logs directory under the userdata folder.
.B --no-log-to-file
prevents redirecting logged output to a file. Log files are created in the logs directory under the userdata folder.
.TP
.BI --max-fps \ fps
the number of frames per second the game can show, the value should be between

View file

@ -261,7 +261,7 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
("log-debug", po::value<std::string>(), "sets the severity level of the specified log domain(s) to 'debug'. Similar to --log-error.")
("log-none", po::value<std::string>(), "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.")
("log-to-file", "log output is written to a file rather than to standard error.")
("no-log-to-file", "log output is written to standard error rather than to a file.")
;
po::options_description multiplayer_opts("Multiplayer options");

View file

@ -1029,17 +1029,21 @@ int main(int argc, char** argv)
// --nobanner needs to be detected before the main command-line parsing happens
// --log-to needs to be detected so the logging output location is set before any actual logging happens
bool nobanner = false;
bool log_to_file = true;
for(const auto& arg : args) {
if(arg == "--nobanner") {
nobanner = true;
break;
}
#ifndef _WIN32
else if(arg == "--log-to-file") {
lg::set_log_to_file();
else if(arg == "--no-log-to-file") {
log_to_file = false;
}
#endif
}
#ifndef _WIN32
if(log_to_file) {
lg::set_log_to_file();
}
#endif
#ifdef _WIN32
bool log_redirect = true, native_console_implied = false;

View file

@ -1,4 +1,4 @@
#!/bin/sh
gamedir=${0%/*}
cd "$gamedir" || exit
exec ./wesnoth --log-to-file "$@"
exec ./wesnoth "$@"