]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/log.cpp
Mgv7 mountains: Remove divide by zero code that creates vast walls
[dragonfireclient.git] / src / log.cpp
index ff2e163333d6c85ac50c229d33ea5307e367d0b1..b3b3f3f1b03af6c17d3d3cd1e2b0f2fc1665fe10 100644 (file)
@@ -29,6 +29,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "porting.h"
 #include "config.h"
 
+#ifdef __ANDROID__
+unsigned int android_log_level_mapping[] {
+               /* LMT_ERROR */   ANDROID_LOG_ERROR,
+               /* LMT_ACTION */  ANDROID_LOG_WARN,
+               /* LMT_INFO */    ANDROID_LOG_INFO,
+               /* LMT_VERBOSE */ ANDROID_LOG_VERBOSE
+       };
+#endif
+
 std::list<ILogOutput*> log_outputs[LMT_NUM_VALUES];
 std::map<threadid_t, std::string> log_threadnames;
 JMutex                            log_threadnamemutex;
@@ -60,6 +69,21 @@ void log_remove_output(ILogOutput *out)
        }
 }
 
+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();
@@ -107,6 +131,9 @@ void log_printline(enum LogMessageLevel lev, const std::string &text)
        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);
@@ -142,7 +169,7 @@ class Logbuf : public std::streambuf
        {
                log_printline(m_lev, m_buf);
 #ifdef __ANDROID__
-               __android_log_print(ANDROID_LOG_ERROR, PROJECT_NAME, "%s", m_buf.c_str());
+               __android_log_print(android_log_level_mapping[m_lev], PROJECT_NAME, "%s", m_buf.c_str());
 #endif
        }