summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-24 12:21:28 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-24 12:21:28 +0200
commit4af89ed7f5d5b830332c796f7038600ad01ec3f5 (patch)
tree6cf5933c40be66e0f7bdd282fd85d04e62925387
parenta7adf93457be4b5a07eff08848cc0b5763722710 (diff)
downloadmad-4af89ed7f5d5b830332c796f7038600ad01ec3f5.tar
mad-4af89ed7f5d5b830332c796f7038600ad01ec3f5.zip
Log-Kategorien als Bitset
-rw-r--r--src/Common/Logger.cpp7
-rw-r--r--src/Common/Logger.h20
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 {