diff options
-rw-r--r-- | project2/common/logger.cpp | 13 | ||||
-rw-r--r-- | project2/common/logger.h | 15 |
2 files changed, 15 insertions, 13 deletions
diff --git a/project2/common/logger.cpp b/project2/common/logger.cpp index 98aaf0b..64df516 100644 --- a/project2/common/logger.cpp +++ b/project2/common/logger.cpp @@ -2,7 +2,7 @@ #define SYSLOG_NAMES 1 // Enables the definition of names in syslog.h #include "logger.h" -#include "instanceStore.impl.h" +#include <factory.impl.h> Log Logger::log; @@ -17,7 +17,7 @@ Log::~Log() } void -Log::setLoggerAt(LogDriverLoader * ldr, int level) +Log::setLoggerAt(LogDriverFactory * ldr, int level) { if (level == -1) { logs.erase(ldr); @@ -26,9 +26,9 @@ Log::setLoggerAt(LogDriverLoader * ldr, int level) logs[ldr] = ldr->create(); } lowestLevel = -1; - for (const auto & log : InstanceSet<LogDriverLoader>::GetAll()) { - if (log->loggerLevel() > lowestLevel) { - lowestLevel = log->loggerLevel(); + for (const auto & log : AdHoc::PluginManager::getDefault()->getAll<LogDriverFactory>()) { + if (log->implementation()->loggerLevel() > lowestLevel) { + lowestLevel = log->implementation()->loggerLevel(); } } } @@ -102,5 +102,6 @@ LogDriverBase::~LogDriverBase() { } -INSTANTIATESTORE(std::string, LogDriverLoader); +template class AdHoc::Factory<LogDriverBase>; +INSTANTIATEPLUGINOF(LogDriverFactory) diff --git a/project2/common/logger.h b/project2/common/logger.h index 0a6398e..cc4409f 100644 --- a/project2/common/logger.h +++ b/project2/common/logger.h @@ -8,7 +8,8 @@ #include <boost/intrusive_ptr.hpp> #include <boost/format.hpp> #include "intrusivePtrBase.h" -#include "genLoader.h" +#include "componentLoader.h" +#include <factory.h> #include <buffer.h> /// Base class for classes providing a logging facility @@ -20,7 +21,7 @@ class LogDriverBase : public virtual IntrusivePtrBase { virtual void message(int priority, const char * msg) const = 0; }; -class LogDriverLoader : public GenLoader<LogDriverBase, std::string> { +class LogDriverFactory : public AdHoc::Factory<LogDriverBase> { public: virtual int loggerLevel() const = 0; }; @@ -28,12 +29,12 @@ class LogDriverLoader : public GenLoader<LogDriverBase, std::string> { class Log { public: typedef boost::intrusive_ptr<LogDriverBase> LogDriverBasePtr; - typedef std::map<LogDriverLoader *, LogDriverBasePtr> LogDrivers; + typedef std::map<LogDriverFactory *, LogDriverBasePtr> LogDrivers; Log(); ~Log(); - void setLoggerAt(LogDriverLoader *, int level); + void setLoggerAt(LogDriverFactory *, int level); void message(int priority, const char * msg) const; void messagef(int priority, const char * msgfmt, ...) const __attribute__ ((format (printf, 3, 4))); @@ -68,9 +69,9 @@ class Logger { }; template<typename LoggerType> -class LogDriverLoaderImpl : public LogDriverLoader::For<LoggerType, LogDriverLoader> { +class LogDriverFactoryImpl : public LogDriverFactory, public ComponentLoader { public: - LogDriverLoaderImpl() : + LogDriverFactoryImpl() : level(LoggerType::level) { } @@ -94,7 +95,7 @@ class LogDriverLoaderImpl : public LogDriverLoader::For<LoggerType, LogDriverLoa mutable boost::intrusive_ptr<LoggerType> instance; }; #define DECLARE_LOGGER_LOADER(N, T) \ - DECLARE_CUSTOM_COMPONENT_LOADER(N, T, LogDriverLoaderImpl<T>, LogDriverLoader); + NAMEDPLUGIN(N, LogDriverFactoryImpl<T>, LogDriverFactory) #endif |