00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #ifndef LOG_LEVELS_H
00028 #define LOG_LEVELS_H
00029
00030
00031
00032 #include <string>
00033
00034
00035
00036 namespace xlog
00037 {
00038
00039
00040
00042
00048 class LogLevel
00049 {
00050 public:
00052 virtual ~LogLevel() { }
00053
00055
00063 virtual bool operator==(std::string const &name) const
00064 { return (!strcasecmp(name.c_str(), "All")); };
00065
00067
00072 virtual char const *header() const { return ""; }
00073 };
00074
00075
00076
00078
00085 #define LOGLEVEL(classname, ancestor, llname) \
00086 class classname : public ancestor \
00087 { \
00088 public: \
00089 virtual bool operator==(std::string const &name) const \
00090 { \
00091 if (!strcasecmp(name.c_str(), llname)) \
00092 return true; \
00093 return ancestor::operator==(name); \
00094 } \
00095 }
00096
00097
00098
00100
00108 #define LOGLEVELH(classname, ancestor, llname, head) \
00109 class classname : public ancestor \
00110 { \
00111 public: \
00112 virtual bool operator==(std::string const &name) const \
00113 { \
00114 if (!strcasecmp(name.c_str(), (llname))) \
00115 return true; \
00116 return ancestor::operator==(name); \
00117 } \
00118 \
00119 virtual char const *header() const { return (head); } \
00120 }
00121
00122
00123
00124 #if DEBUG
00125 LOGLEVELH(LogDebug, LogLevel, "Debug", "debug: ");
00126 #endif
00127 LOGLEVEL(LogInfo, LogLevel, "Info");
00128 LOGLEVEL(LogNotice, LogLevel, "Notice");
00129 LOGLEVELH(LogWarning, LogLevel, "Warning", "warning: ");
00130 LOGLEVELH(LogError, LogLevel, "Error", "Error: ");
00131 LOGLEVELH(LogCritical, LogLevel, "Critical", "Critical error: ");
00132 LOGLEVELH(LogFatal, LogLevel, "Fatal", "FATAL: ");
00133
00134
00135
00136 }
00137
00138
00139
00140 #endif