mirror of https://github.com/stella-emu/stella.git
Make logger threadsafe.
This commit is contained in:
parent
1f94a79b1c
commit
cc0d101d98
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue