diff options
author | you <ovvv@web.de> | 2018-03-04 17:34:36 +0100 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2018-03-04 17:34:36 +0100 |
commit | 540e07e3ef07de760100c2948dc3a756e48b1c72 (patch) | |
tree | 80faec4d957688f1f83c5285386c2d413de3413d /src/main.cpp | |
parent | 929792e15ea50943e7fd23925c3d1d431dfd8a02 (diff) | |
download | minetest-540e07e3ef07de760100c2948dc3a756e48b1c72.tar.gz minetest-540e07e3ef07de760100c2948dc3a756e48b1c72.tar.bz2 minetest-540e07e3ef07de760100c2948dc3a756e48b1c72.zip |
Fix missing warningstream (or similar problem) (#7034)
Use the --color command line parameter instead of a setting for coloured logs
This fixes the missing warningstream bug, g_settings->get mustn't be used there.
Also, the decision about en- or disabling log colours fits better to the command line parameters than minetest settings.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 7f9f0967e..d9073cfb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -266,6 +266,15 @@ static void set_allowed_options(OptionList *allowed_options) "'name' lists names, 'both' lists both)")))); allowed_options->insert(std::make_pair("quiet", ValueSpec(VALUETYPE_FLAG, _("Print to console errors only")))); +#if !defined(_WIN32) + allowed_options->insert(std::make_pair("color", ValueSpec(VALUETYPE_STRING, + _("Coloured logs ('always', 'never' or 'auto'), defaults to 'auto'" + )))); +#else + allowed_options->insert(std::make_pair("color", ValueSpec(VALUETYPE_STRING, + _("Coloured logs ('always' or 'never'), defaults to 'never'" + )))); +#endif allowed_options->insert(std::make_pair("info", ValueSpec(VALUETYPE_FLAG, _("Print more information to console")))); allowed_options->insert(std::make_pair("verbose", ValueSpec(VALUETYPE_FLAG, @@ -393,6 +402,17 @@ static void setup_log_params(const Settings &cmd_args) g_logger.addOutputMaxLevel(&stderr_output, LL_ERROR); } + // Coloured log messages (see log.h) + if (cmd_args.exists("color")) { + std::string mode = cmd_args.get("color"); + if (mode == "auto") + Logger::color_mode = LOG_COLOR_AUTO; + else if (mode == "always") + Logger::color_mode = LOG_COLOR_ALWAYS; + else + Logger::color_mode = LOG_COLOR_NEVER; + } + // If trace is enabled, enable logging of certain things if (cmd_args.getFlag("trace")) { dstream << _("Enabling trace level debug output") << std::endl; |