diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-22 18:25:17 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-22 18:25:17 +0200 |
commit | aee9955f2e16e0a61f1fee40548c478b45f507a6 (patch) | |
tree | da3a2f7aa1bc520bdae352efc707da1d5b31de38 /src/Common/Logger.h | |
parent | 1af3eab2b23c67795b188e5edaf83bf47a8879bd (diff) | |
parent | 14ff48a0e6d23dce53810c0292816950ba7b9f71 (diff) | |
download | mad-aee9955f2e16e0a61f1fee40548c478b45f507a6.tar mad-aee9955f2e16e0a61f1fee40548c478b45f507a6.zip |
Merge with 435981ea6ae030a50fbbbffb03f5402bdcced076
Diffstat (limited to 'src/Common/Logger.h')
-rw-r--r-- | src/Common/Logger.h | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/Common/Logger.h b/src/Common/Logger.h index ba14347..360b746 100644 --- a/src/Common/Logger.h +++ b/src/Common/Logger.h @@ -20,10 +20,13 @@ #ifndef MAD_COMMON_LOGGER_H_ #define MAD_COMMON_LOGGER_H_ +#define CATEGORYCOUNT 9 //Please insert the number of categories + #include <algorithm> #include <cstdarg> #include <list> #include <string> +#include <set> namespace Mad { namespace Common { @@ -34,28 +37,27 @@ class Logger { CRITICAL, ERROR, WARNING, DEFAULT, VERBOSE, DEBUG }; enum MessageCategory { - ALL, SYSTEM, NETWORK, DAEMON, USER, DISK, PROGRAM, GENERAL + SYSTEM, NETWORK, DAEMON, USER, DISK, PROGRAM, GENERAL }; private: static std::list<Logger*> loggers; - MessageCategory category; + std::set<MessageCategory> categories; MessageLevel level; static void logfv(MessageCategory category, MessageLevel level, const char *format, va_list ap); protected: - Logger() : level(DEFAULT), category(ALL) {} - + Logger() : level(DEFAULT) {} virtual void logMessage(MessageCategory category, MessageLevel level, const std::string &message) = 0; public: static void log(MessageCategory category, MessageLevel level, const std::string &message); static void log(MessageLevel level, const std::string &message) { - log(ALL, level, message); + log(GENERAL, level, message); } static void log(const std::string &message) { - log(ALL, DEFAULT, message); + log(GENERAL, DEFAULT, message); } static void logf(MessageCategory category, MessageLevel level, const char *format, ...); @@ -72,12 +74,26 @@ class Logger { loggers.erase(it); } - MessageCategory getCategory() const { - return category; - } - void setCategory(MessageCategory newCategory) { - category = newCategory; + categories.insert(newCategory); + } + void unsetCategory(MessageCategory oldCategory) { + categories.erase(oldCategory); + } + void setAllCategories() { + //each loop represents one category + for(int category = 1; category <= CATEGORYCOUNT; category++) { + categories.insert((MessageCategory)category); + } + } + void unsetAllCategories() { + categories.clear(); + } + bool isCategorySet(MessageCategory category) { + if(categories.find(category) == categories.end()) + return false; + else + return true; } MessageLevel getLevel() const { |