mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-10 09:50:17 +02:00
52 lines
812 B
C++
52 lines
812 B
C++
#include "StdInc.h"
|
|
#include "CLogManager.h"
|
|
|
|
#include "CLogger.h"
|
|
|
|
CLogManager * CLogManager::instance = nullptr;
|
|
|
|
boost::mutex CLogManager::smx;
|
|
|
|
CLogManager * CLogManager::get()
|
|
{
|
|
TLockGuard _(smx);
|
|
if(!instance)
|
|
{
|
|
instance = new CLogManager();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
CLogManager::CLogManager()
|
|
{
|
|
|
|
}
|
|
|
|
CLogManager::~CLogManager()
|
|
{
|
|
BOOST_FOREACH(auto & i, loggers)
|
|
{
|
|
delete i.second;
|
|
}
|
|
}
|
|
|
|
void CLogManager::addLogger(CGLogger * logger)
|
|
{
|
|
TWriteLock _(mx);
|
|
loggers[logger->getDomain().getName()] = logger;
|
|
}
|
|
|
|
CGLogger * CLogManager::getLogger(const CLoggerDomain & domain)
|
|
{
|
|
TReadLock _(mx);
|
|
auto it = loggers.find(domain.getName());
|
|
if(it != loggers.end())
|
|
{
|
|
return it->second;
|
|
}
|
|
else
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|