From fae8ca32af7407653d21f7cbc4e9ea79751faab8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 24 Sep 2008 12:37:13 +0200 Subject: Benutze Bitset-Klasse f?r die Logger-Kategorien --- src/Common/Logger.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/Common/Logger.h') diff --git a/src/Common/Logger.h b/src/Common/Logger.h index 64aeadb..56abd61 100644 --- a/src/Common/Logger.h +++ b/src/Common/Logger.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include namespace Mad { namespace Common { @@ -36,18 +36,18 @@ class Logger { }; enum MessageCategory { - SYSTEM = 0x0001, NETWORK = 0x0002, DAEMON = 0x0004, USER = 0x0008, DISK = 0x0010, PROGRAM = 0x0020, GENERAL = 0x0040 + SYSTEM, NETWORK, DAEMON, USER, DISK, PROGRAM, GENERAL }; private: static std::list loggers; - uint16_t categories; + std::bitset<16> categories; MessageLevel level; static void logfv(MessageCategory category, MessageLevel level, const char *format, va_list ap); protected: - Logger() : categories(0xFFFF), level(DEFAULT) {} + Logger() : level(DEFAULT) {setAllCategories();} virtual void logMessage(MessageCategory category, MessageLevel level, const std::string &message) = 0; public: @@ -74,23 +74,23 @@ class Logger { } void setCategory(MessageCategory newCategory) { - categories |= newCategory; + categories.set(newCategory); } void unsetCategory(MessageCategory oldCategory) { - categories &= ~oldCategory; + categories.reset(oldCategory); } void setAllCategories() { - categories = 0xFFFF; + categories.set(); } void unsetAllCategories() { - categories = 0; + categories.reset(); } bool isCategorySet(MessageCategory category) { - return ((categories & category) != 0); + return categories.test(category); } MessageLevel getLevel() const { -- cgit v1.2.3