diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-11 12:15:03 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-11 12:15:03 +0000 |
commit | d17465716790010b6e3221f9ce49272110276ccf (patch) | |
tree | d929b9c717e789d818d0eefbfe6e018974ae48f6 /include/inspircd.h | |
parent | 312d49abb008dccf9871b663decaa1bacf18c20a (diff) |
Now two types of log macro, log() and ilog(). log() assumes an InspIRCd object called ServerInstance, ilog() takes an InspIRCd object as first param.
TODO: Run a regexp over these, using perl, to translate them into InspIRCd::Log calls and then eliminate the macro :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4879 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include/inspircd.h')
-rw-r--r-- | include/inspircd.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 699d910dc..3800c09ab 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -36,6 +36,28 @@ /* Crucial defines */ #define ETIREDGERBILS EAGAIN +/** Debug levels for use with InspIRCd::Log() + */ +enum DebugLevel +{ + DEBUG = 10, + VERBOSE = 20, + DEFAULT = 30, + SPARSE = 40, + NONE = 50, +}; + +/* I'm not entirely happy with this, the ## before 'args' is a g++ extension. + * The problem is that if you #define log(l, x, args...) and then call it + * with only two parameters, you get do_log(l, x, ), which is a syntax error... + * The ## tells g++ to remove the trailing comma... + * If this is ever an issue, we can just have an #ifndef GCC then #define log(a...) do_log(a) + */ +#define STRINGIFY2(x) #x +#define STRINGIFY(x) STRINGIFY2(x) +#define log(l, x, args...) ServerInstance->Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) +#define ilog(i, l, x, args...) i->Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) + /* This define is used in place of strcmp when we * want to check if a char* string contains only one * letter. Pretty fast, its just two compares and an @@ -43,7 +65,7 @@ */ #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) ) -#define DELETE(x) { InspIRCd::Log(DEBUG,"%s:%d: delete()",__FILE__,__LINE__); if (x) { delete x; x = NULL; } else InspIRCd::Log(DEBUG,"Attempt to delete NULL pointer!"); } +#define DELETE(x) {if (x) { delete x; x = NULL; }} template<typename T> inline std::string ConvToStr(const T &in) { @@ -177,7 +199,6 @@ class InspIRCd : public classbase bool IsChannel(const char *chname); - static void Error(int status); static void Rehash(int status); static void Exit(int status); @@ -319,8 +340,8 @@ class InspIRCd : public classbase bool UnloadModule(const char* filename); InspIRCd(int argc, char** argv); void DoOneIteration(bool process_module_sockets); - static void Log(int level, const char* text, ...); - static void Log(int level, const std::string &text); + void Log(int level, const char* text, ...); + void Log(int level, const std::string &text); int Run(); }; |