summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-24 12:37:13 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-24 12:37:13 +0200
commitfae8ca32af7407653d21f7cbc4e9ea79751faab8 (patch)
tree6da7cb6557ddc7e8dc4b037f4207b0b34ad6a537
parent4af89ed7f5d5b830332c796f7038600ad01ec3f5 (diff)
downloadmad-fae8ca32af7407653d21f7cbc4e9ea79751faab8.tar
mad-fae8ca32af7407653d21f7cbc4e9ea79751faab8.zip
Benutze Bitset-Klasse f?r die Logger-Kategorien
-rw-r--r--src/Common/Logger.h18
1 files changed, 9 insertions, 9 deletions
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 <cstdarg>
#include <list>
#include <string>
-#include <stdint.h>
+#include <bitset>
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<Logger*> 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 {