-enum LogMessageLevel {
- LMT_ERROR, /* Something failed ("invalid map data on disk, block (2,2,1)") */
- LMT_ACTION, /* In-game actions ("celeron55 placed block at (12,4,-5)") */
- LMT_INFO, /* More deep info ("saving map on disk (only_modified=true)") */
- LMT_VERBOSE, /* Flood-style ("loaded block (2,2,2) from disk") */
- LMT_NUM_VALUES,
+ void log(LogLevel lev, const std::string &text);
+ // Logs without a prefix
+ void logRaw(LogLevel lev, const std::string &text);
+
+ void setTraceEnabled(bool enable) { m_trace_enabled = enable; }
+ bool getTraceEnabled() { return m_trace_enabled; }
+
+ 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,
+ const std::string &time, const std::string &thread_name,
+ const std::string &payload_text);
+
+ const std::string getThreadName();
+
+ std::vector<ILogOutput *> m_outputs[LL_MAX];
+
+ // Should implement atomic loads and stores (even though it's only
+ // written to when one thread has access currently).
+ // Works on all known architectures (x86, ARM, MIPS).
+ volatile bool m_silenced_levels[LL_MAX];
+ std::map<std::thread::id, std::string> m_thread_names;
+ mutable std::mutex m_mutex;
+ bool m_trace_enabled;