diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Common/Logger.cpp | 7 | ||||
-rw-r--r-- | src/Common/Logger.h | 20 |
2 files changed, 11 insertions, 16 deletions
diff --git a/src/Common/Logger.cpp b/src/Common/Logger.cpp index 6206b59..859a77d 100644 --- a/src/Common/Logger.cpp +++ b/src/Common/Logger.cpp @@ -86,12 +86,5 @@ void Logger::logf(const char *format, ...) { va_end(ap); } -void Logger::setAllCategories() { - static const MessageCategory categoryList[] = {SYSTEM, NETWORK, DAEMON, USER, DISK, PROGRAM, GENERAL}; - - for(unsigned int i = 0; i < sizeof(categoryList)/sizeof(categoryList[0]); ++i) - setCategory(categoryList[i]); -} - } } diff --git a/src/Common/Logger.h b/src/Common/Logger.h index ad75fbe..64aeadb 100644 --- a/src/Common/Logger.h +++ b/src/Common/Logger.h @@ -24,7 +24,7 @@ #include <cstdarg> #include <list> #include <string> -#include <set> +#include <stdint.h> namespace Mad { namespace Common { @@ -36,18 +36,18 @@ class Logger { }; enum MessageCategory { - SYSTEM, NETWORK, DAEMON, USER, DISK, PROGRAM, GENERAL + SYSTEM = 0x0001, NETWORK = 0x0002, DAEMON = 0x0004, USER = 0x0008, DISK = 0x0010, PROGRAM = 0x0020, GENERAL = 0x0040 }; private: static std::list<Logger*> loggers; - std::set<MessageCategory> categories; + uint16_t categories; MessageLevel level; static void logfv(MessageCategory category, MessageLevel level, const char *format, va_list ap); protected: - Logger() : level(DEFAULT) {setAllCategories();} + Logger() : categories(0xFFFF), level(DEFAULT) {} virtual void logMessage(MessageCategory category, MessageLevel level, const std::string &message) = 0; public: @@ -74,21 +74,23 @@ class Logger { } void setCategory(MessageCategory newCategory) { - categories.insert(newCategory); + categories |= newCategory; } void unsetCategory(MessageCategory oldCategory) { - categories.erase(oldCategory); + categories &= ~oldCategory; } - void setAllCategories(); + void setAllCategories() { + categories = 0xFFFF; + } void unsetAllCategories() { - categories.clear(); + categories = 0; } bool isCategorySet(MessageCategory category) { - return (categories.find(category) != categories.end()); + return ((categories & category) != 0); } MessageLevel getLevel() const { |