]> git.lizzy.rs Git - minetest.git/blobdiff - src/log.h
Randomwalk caves: Add parameters for number, proportion flooded. Allow small caves...
[minetest.git] / src / log.h
index 506137739a06a9d6f3b861e8eae075127f679d34..6350d8a8659b0ff0d555326d525b513e406c1105 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #if !defined(_WIN32)  // POSIX
        #include <unistd.h>
 #endif
-#include "settings.h"
 #include "irrlichttypes.h"
 
 class ILogOutput;
@@ -43,6 +42,12 @@ enum LogLevel {
        LL_MAX,
 };
 
+enum LogColor {
+       LOG_COLOR_NEVER,
+       LOG_COLOR_ALWAYS,
+       LOG_COLOR_AUTO,
+};
+
 typedef u8 LogLevelMask;
 #define LOGLEVEL_TO_MASKLEVEL(x) (1 << x)
 
@@ -68,6 +73,8 @@ class Logger {
        static LogLevel stringToLevel(const std::string &name);
        static const std::string getLevelLabel(LogLevel lev);
 
+       static LogColor color_mode;
+
 private:
        void logToOutputsRaw(LogLevel, const std::string &line);
        void logToOutputs(LogLevel, const std::string &combined,
@@ -119,10 +126,9 @@ class StreamLogOutput : public ICombinedLogOutput {
 
        void logRaw(LogLevel lev, const std::string &line)
        {
-               static const std::string use_logcolor = g_settings->get("log_color");
-
-               bool colored = use_logcolor == "detect" ? is_tty : use_logcolor == "yes";
-               if (colored)
+               bool colored_message = (Logger::color_mode == LOG_COLOR_ALWAYS) ||
+                       (Logger::color_mode == LOG_COLOR_AUTO && is_tty);
+               if (colored_message)
                        switch (lev) {
                        case LL_ERROR:
                                // error is red
@@ -142,12 +148,12 @@ class StreamLogOutput : public ICombinedLogOutput {
                                break;
                        default:
                                // action is white
-                               colored = false;
+                               colored_message = false;
                        }
 
                m_stream << line << std::endl;
 
-               if (colored)
+               if (colored_message)
                        // reset to white color
                        m_stream << "\033[0m";
        }
@@ -159,7 +165,7 @@ class StreamLogOutput : public ICombinedLogOutput {
 
 class FileLogOutput : public ICombinedLogOutput {
 public:
-       void open(const std::string &filename);
+       void setFile(const std::string &filename, s64 file_size_max);
 
        void logRaw(LogLevel lev, const std::string &line)
        {