ParticleSpawner: Fix crash when attaching to invisible entity
[oweals/minetest.git] / src / log.h
index 952ebadb1959a8544ea2b1f1a139e33007136c9f..856d3479b94d44cfd8187591440ee859ca0b5520 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -118,54 +118,22 @@ public:
                m_stream(stream)
        {
 #if !defined(_WIN32)
-               colored = (Logger::color_mode == LOG_COLOR_ALWAYS) ||
-                       (Logger::color_mode == LOG_COLOR_AUTO && isatty(fileno(stdout)));
+               is_tty = isatty(fileno(stdout));
 #else
-               colored = Logger::color_mode == LOG_COLOR_ALWAYS;
+               is_tty = false;
 #endif
        }
 
-       void logRaw(LogLevel lev, const std::string &line)
-       {
-               bool colored_message = colored;
-               if (colored_message)
-                       switch (lev) {
-                       case LL_ERROR:
-                               // error is red
-                               m_stream << "\033[91m";
-                               break;
-                       case LL_WARNING:
-                               // warning is yellow
-                               m_stream << "\033[93m";
-                               break;
-                       case LL_INFO:
-                               // info is a bit dark
-                               m_stream << "\033[37m";
-                               break;
-                       case LL_VERBOSE:
-                               // verbose is darker than info
-                               m_stream << "\033[2m";
-                               break;
-                       default:
-                               // action is white
-                               colored_message = false;
-                       }
-
-               m_stream << line << std::endl;
-
-               if (colored_message)
-                       // reset to white color
-                       m_stream << "\033[0m";
-       }
+       void logRaw(LogLevel lev, const std::string &line);
 
 private:
        std::ostream &m_stream;
-       bool colored;
+       bool is_tty;
 };
 
 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)
        {
@@ -178,23 +146,27 @@ private:
 
 class LogOutputBuffer : public ICombinedLogOutput {
 public:
-       LogOutputBuffer(Logger &logger, LogLevel lev) :
+       LogOutputBuffer(Logger &logger) :
                m_logger(logger)
        {
-               m_logger.addOutput(this, lev);
-       }
+               updateLogLevel();
+       };
 
-       ~LogOutputBuffer()
+       virtual ~LogOutputBuffer()
        {
                m_logger.removeOutput(this);
        }
 
-       void logRaw(LogLevel lev, const std::string &line)
+       void updateLogLevel();
+
+       void logRaw(LogLevel lev, const std::string &line);
+
+       void clear()
        {
-               m_buffer.push(line);
+               m_buffer = std::queue<std::string>();
        }
 
-       bool empty()
+       bool empty() const
        {
                return m_buffer.empty();
        }