#if !defined(_WIN32) // POSIX
#include <unistd.h>
#endif
-#include "settings.h"
#include "irrlichttypes.h"
class ILogOutput;
LL_MAX,
};
+enum LogColor {
+ LOG_COLOR_NEVER,
+ LOG_COLOR_ALWAYS,
+ LOG_COLOR_AUTO,
+};
+
typedef u8 LogLevelMask;
#define LOGLEVEL_TO_MASKLEVEL(x) (1 << x)
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,
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
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";
}
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)
{