From 6e0de7b42cce06aff5ae18664b61d6a1c3484f5e Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 27 Nov 2011 13:52:10 +0200 Subject: [PATCH] Add log_remove_output and log_deregister_thread --- src/log.cpp | 17 +++++++++++++++++ src/log.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/log.cpp b/src/log.cpp index cc981dad..188b9b67 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include #include "threads.h" #include "debug.h" #include "gettime.h" @@ -46,12 +47,28 @@ void log_add_output_all_levs(ILogOutput *out) log_outputs[i].push_back(out); } +void log_remove_output(ILogOutput *out) +{ + for(int i=0; i::iterator it = + std::find(log_outputs[i].begin(), log_outputs[i].end(), out); + if(it != log_outputs[i].end()) + log_outputs[i].erase(it); + } +} + void log_register_thread(const std::string &name) { threadid_t id = get_current_thread_id(); log_threadnames[id] = name; } +void log_deregister_thread() +{ + threadid_t id = get_current_thread_id(); + log_threadnames.erase(id); +} + static std::string get_lev_string(enum LogMessageLevel lev) { switch(lev){ diff --git a/src/log.h b/src/log.h index a5e840a4..1d087429 100644 --- a/src/log.h +++ b/src/log.h @@ -48,8 +48,10 @@ public: 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_register_thread(const std::string &name); +void log_deregister_thread(); void log_printline(enum LogMessageLevel lev, const std::string &text); -- 2.30.2