Make logger threadsafe.

This commit is contained in:
Christian Speckner 2021-10-11 17:59:00 +02:00
parent 1f94a79b1c
commit cc0d101d98
2 changed files with 5 additions and 0 deletions

View File

@ -51,6 +51,8 @@ void Logger::debug(const string& message)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Logger::logMessage(const string& message, Level level)
{
std::lock_guard<std::mutex> lock(mutex);
if(level == Logger::Level::ERR)
{
cout << message << endl << std::flush;

View File

@ -19,6 +19,7 @@
#define LOGGER_HXX
#include <functional>
#include <mutex>
#include "bspf.hxx"
@ -62,6 +63,8 @@ class Logger {
// The list of log messages
string myLogMessages;
std::mutex mutex;
private:
void logMessage(const string& message, Level level);