aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Log.cpp5
-rw-r--r--src/Log.h3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/Log.cpp b/src/Log.cpp
index f8f7d7f..90548af 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -74,7 +74,10 @@ void Logger::logstr(log_level_t level, std::string message)
(*it)->log(level, message);
}
- std::cerr << levels_as_str[level] << " " << message << std::endl;
+ {
+ std::lock_guard<std::mutex> guard(m_cerr_mutex);
+ std::cerr << levels_as_str[level] << " " << message << std::endl;
+ }
}
diff --git a/src/Log.h b/src/Log.h
index 7be6df8..81490b2 100644
--- a/src/Log.h
+++ b/src/Log.h
@@ -39,6 +39,7 @@
#include <stdexcept>
#include <string>
#include <map>
+#include <mutex>
#define SYSLOG_IDENT "ODR-DabMux"
#define SYSLOG_FACILITY LOG_LOCAL0
@@ -146,6 +147,8 @@ class Logger {
private:
std::list<LogBackend*> backends;
+
+ std::mutex m_cerr_mutex;
};
extern Logger etiLog;