add mutex for debug logs.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -11,6 +11,7 @@ decltype(Debug::logFunc_) Debug::logFunc_ = nullptr;
|
||||
decltype(Debug::errFunc_) Debug::errFunc_ = nullptr;
|
||||
decltype(Debug::fs_) Debug::fs_;
|
||||
decltype(Debug::ss_) Debug::ss_;
|
||||
decltype(Debug::mutex_) Debug::mutex_;
|
||||
|
||||
|
||||
void Debug::Initialize()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <time.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <mutex>
|
||||
#include "IUnityInterface.h"
|
||||
|
||||
// Logging
|
||||
@@ -107,6 +108,7 @@ public:
|
||||
template <class Arg, class... RestArgs>
|
||||
static void Log(Arg&& arg, RestArgs&&... restArgs)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
Output("[uDD::Log]");
|
||||
OutputTime();
|
||||
Output(" ");
|
||||
@@ -116,6 +118,7 @@ public:
|
||||
template <class Arg, class... RestArgs>
|
||||
static void Error(Arg&& arg, RestArgs&&... restArgs)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
Output("[uDD::Err]");
|
||||
OutputTime();
|
||||
Output(" ");
|
||||
@@ -129,4 +132,5 @@ private:
|
||||
static std::ostringstream ss_;
|
||||
static DebugLogFuncPtr logFunc_;
|
||||
static DebugLogFuncPtr errFunc_;
|
||||
static std::mutex mutex_;
|
||||
};
|
||||
Reference in New Issue
Block a user