summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorHybridDog <ovvv@web.de>2019-03-05 08:14:33 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2019-03-05 08:14:33 +0100
commitee698770b98145bbb39f8671f8586e835b2e9ab4 (patch)
tree26770712c9b67791a9dd75dcf507efe908f1048f /src/main.cpp
parente19565c170ba8baf7a90945beb44cb1ef7292e50 (diff)
downloadminetest-ee698770b98145bbb39f8671f8586e835b2e9ab4.tar.gz
minetest-ee698770b98145bbb39f8671f8586e835b2e9ab4.tar.bz2
minetest-ee698770b98145bbb39f8671f8586e835b2e9ab4.zip
Fix --color command line parameter ignorance (#7173)
* Fix color command line parameter ignorance * coloured log: Support detecting the tty on windows * Print an error message when setting something invalid as color mode instead of silently using mode never * Revert "coloured log: Support detecting the tty on windows" This reverts commit 4c9fc6366487ac0e6799e181796ca594797bb6f8. It didn't work for travis and belongs to a separate PR * Allow adjusting the log color with an environment variable If --color is not passed to minetest, is used to decide on the log colorization. Minetest settings can not be used instead of an environment variable because logs may appear before loading them. * fix empty if body
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 26ad978c6..e4e47b1ac 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -407,14 +407,25 @@ static void setup_log_params(const Settings &cmd_args)
}
// Coloured log messages (see log.h)
+ std::string color_mode;
if (cmd_args.exists("color")) {
- std::string mode = cmd_args.get("color");
- if (mode == "auto")
+ color_mode = cmd_args.get("color");
+#if !defined(_WIN32)
+ } else {
+ char *color_mode_env = getenv("MT_LOGCOLOR");
+ if (color_mode_env)
+ color_mode = color_mode_env;
+#endif
+ }
+ if (color_mode != "") {
+ if (color_mode == "auto")
Logger::color_mode = LOG_COLOR_AUTO;
- else if (mode == "always")
+ else if (color_mode == "always")
Logger::color_mode = LOG_COLOR_ALWAYS;
- else
+ else if (color_mode == "never")
Logger::color_mode = LOG_COLOR_NEVER;
+ else
+ errorstream << "Invalid color mode: " << color_mode << std::endl;
}
// If trace is enabled, enable logging of certain things