summaryrefslogtreecommitdiff
path: root/src/log.h
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2020-05-14 19:26:15 +0200
committerGitHub <noreply@github.com>2020-05-14 19:26:15 +0200
commit836dd4a1e4f97411519578cd9e59b6dbe3b2c00d (patch)
tree975ba90d47944c342536f0f7c5ee068b47dd7185 /src/log.h
parent2d7e000cfe578340a126d7101ac98c0de29b66b6 (diff)
downloadminetest-836dd4a1e4f97411519578cd9e59b6dbe3b2c00d.tar.gz
minetest-836dd4a1e4f97411519578cd9e59b6dbe3b2c00d.tar.bz2
minetest-836dd4a1e4f97411519578cd9e59b6dbe3b2c00d.zip
Add chat_log_level setting (#9223)
Log all higher levels in LogOutputBuffer Move StreamLogOutput::logRaw to source file like LogOutputBuffer::logRaw for compiling speed
Diffstat (limited to 'src/log.h')
-rw-r--r--src/log.h52
1 files changed, 12 insertions, 40 deletions
diff --git a/src/log.h b/src/log.h
index 6350d8a86..856d3479b 100644
--- a/src/log.h
+++ b/src/log.h
@@ -124,39 +124,7 @@ public:
#endif
}
- void logRaw(LogLevel lev, const std::string &line)
- {
- 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
- 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;
@@ -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();
}