summaryrefslogtreecommitdiffstats
path: root/src/Core
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core')
-rw-r--r--src/Core/LogManager.cpp12
-rw-r--r--src/Core/LogManager.h16
2 files changed, 14 insertions, 14 deletions
diff --git a/src/Core/LogManager.cpp b/src/Core/LogManager.cpp
index bf9767b..91149f9 100644
--- a/src/Core/LogManager.cpp
+++ b/src/Core/LogManager.cpp
@@ -56,7 +56,7 @@ bool LogManager::handleConfigEntry(const ConfigEntry &entry, bool handled) {
if(entry[0].getKey().matches("Logger")) {
if(entry[0][0].matches("Console")) {
if(entry[1].empty()) {
- registerLogger(static_cast<Logger*>(&consoleLogger));
+ registerLogger(boost::static_pointer_cast<Logger>(consoleLogger));
return true;
}
}
@@ -71,10 +71,10 @@ bool LogManager::handleConfigEntry(const ConfigEntry &entry, bool handled) {
void LogManager::configFinished() {
if(loggers.empty())
- registerLogger(static_cast<Logger*>(&consoleLogger));
+ registerLogger(boost::static_pointer_cast<Logger>(consoleLogger));
// TODO Debug
- consoleLogger.Logger::setLevel(LoggerBase::DEBUG);
+ consoleLogger->Logger::setLevel(LoggerBase::DEBUG);
queueLock.lock();
configured = true;
@@ -84,7 +84,7 @@ void LogManager::configFinished() {
void LogManager::log(MessageCategory category, MessageLevel level, time_t timestamp, const std::string &message) {
if(level == LoggerBase::CRITICAL)
- consoleLogger.logMessageDirect(category, level, timestamp, message);
+ consoleLogger->logMessageDirect(category, level, timestamp, message);
queueLock.lock();
Message m = {category, level, timestamp, message};
@@ -116,7 +116,7 @@ void LogManager::loggerThread() {
lock.unlock();
loggerLock.lock();
- for(std::set<Logger*>::iterator logger = loggers.begin(); logger != loggers.end(); ++logger) {
+ for(std::set<boost::shared_ptr<Logger> >::iterator logger = loggers.begin(); logger != loggers.end(); ++logger) {
if((*logger)->getLevel() >= message.level && (*logger)->isCategorySet(message.category))
(*logger)->logMessage(message.category, message.level, message.timestamp, message.message);
}
@@ -131,7 +131,7 @@ void LogManager::loggerThread() {
lock.unlock();
remoteLoggerLock.lock();
- for(std::set<RemoteLogger*>::iterator logger = remoteLoggers.begin(); logger != remoteLoggers.end(); ++logger) {
+ for(std::set<boost::shared_ptr<RemoteLogger> >::iterator logger = remoteLoggers.begin(); logger != remoteLoggers.end(); ++logger) {
if((*logger)->getLevel() >= message.level && (*logger)->isCategorySet(message.category))
(*logger)->logMessage(message.category, message.level, message.timestamp, message.message, message.source);
}
diff --git a/src/Core/LogManager.h b/src/Core/LogManager.h
index 6d75b82..8c8d091 100644
--- a/src/Core/LogManager.h
+++ b/src/Core/LogManager.h
@@ -78,10 +78,10 @@ class LogManager : public Configurable {
static LogManager logManager;
- ConsoleLogger consoleLogger;
+ boost::shared_ptr<ConsoleLogger> consoleLogger;
- std::set<Logger*> loggers;
- std::set<RemoteLogger*> remoteLoggers;
+ std::set<boost::shared_ptr<Logger> > loggers;
+ std::set<boost::shared_ptr<RemoteLogger> > remoteLoggers;
bool configured, running;
boost::mutex queueLock;
@@ -101,7 +101,7 @@ class LogManager : public Configurable {
queueCond.notify_one();
}
- LogManager() : configured(false), running(false) {}
+ LogManager() : consoleLogger(new ConsoleLogger), configured(false), running(false) {}
protected:
virtual bool handleConfigEntry(const ConfigEntry &entry, bool handled);
@@ -111,25 +111,25 @@ class LogManager : public Configurable {
void log(MessageCategory category, MessageLevel level, time_t timestamp, const std::string &message);
void log(MessageCategory category, MessageLevel level, time_t timestamp, const std::string &message, const std::string &source);
- void registerLogger(Logger *logger) {
+ void registerLogger(boost::shared_ptr<Logger> logger) {
loggerLock.lock();
loggers.insert(logger);
loggerLock.unlock();
}
- void unregisterLogger(Logger *logger) {
+ void unregisterLogger(boost::shared_ptr<Logger> logger) {
loggerLock.lock();
loggers.erase(logger);
loggerLock.unlock();
}
- void registerLogger(RemoteLogger *logger) {
+ void registerLogger(boost::shared_ptr<RemoteLogger> logger) {
remoteLoggerLock.lock();
remoteLoggers.insert(logger);
remoteLoggerLock.unlock();
}
- void unregisterLogger(RemoteLogger *logger) {
+ void unregisterLogger(boost::shared_ptr<RemoteLogger> logger) {
remoteLoggerLock.lock();
remoteLoggers.erase(logger);
remoteLoggerLock.unlock();