}
}
+void log_set_lev_silence(enum LogMessageLevel lev, bool silence)
+{
+ log_threadnamemutex.Lock();
+
+ for (std::list<ILogOutput *>::iterator
+ it = log_outputs[lev].begin();
+ it != log_outputs[lev].end();
+ ++it) {
+ ILogOutput *out = *it;
+ out->silence = silence;
+ }
+
+ log_threadnamemutex.Unlock();
+}
+
void log_register_thread(const std::string &name)
{
threadid_t id = get_current_thread_id();
for(std::list<ILogOutput*>::iterator i = log_outputs[lev].begin();
i != log_outputs[lev].end(); i++){
ILogOutput *out = *i;
+ if (out->silence)
+ continue;
+
out->printLog(os.str());
out->printLog(os.str(), lev);
out->printLog(lev, text);
/*
Use this for logging everything.
-
+
If you need to explicitly print something, use dstream or cout or cerr.
*/
class ILogOutput
{
public:
+ ILogOutput() :
+ silence(false)
+ {}
+
/* line: Full line with timestamp, level and thread */
virtual void printLog(const std::string &line){};
/* line: Full line with timestamp, level and thread */
virtual void printLog(const std::string &line, enum LogMessageLevel lev){};
/* line: Only actual printed text */
virtual void printLog(enum LogMessageLevel lev, const std::string &line){};
+
+ bool silence;
};
void log_add_output(ILogOutput *out, enum LogMessageLevel lev);
void log_add_output_maxlev(ILogOutput *out, enum LogMessageLevel lev);
void log_add_output_all_levs(ILogOutput *out);
void log_remove_output(ILogOutput *out);
+void log_set_lev_silence(enum LogMessageLevel lev, bool silence);
void log_register_thread(const std::string &name);
void log_deregister_thread();
IWritableNodeDefManager *ndef = createNodeDefManager();
define_some_nodes(idef, ndef);
+ log_set_lev_silence(LMT_ERROR, true);
+
infostream<<"run_tests() started"<<std::endl;
TEST(TestUtilities);
TEST(TestPath);
dout_con<<"=== END RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl;
}
+ log_set_lev_silence(LMT_ERROR, false);
+
delete idef;
delete ndef;