diff options
-rw-r--r-- | include/helperfuncs.h | 12 | ||||
-rw-r--r-- | src/cmd_pong.cpp | 1 | ||||
-rw-r--r-- | src/cmd_topic.cpp | 1 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 2 | ||||
-rw-r--r-- | src/socketengine.cpp | 1 |
5 files changed, 15 insertions, 2 deletions
diff --git a/include/helperfuncs.h b/include/helperfuncs.h index c9645144f..45c4da6f0 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -35,7 +35,17 @@ #define SPARSE 40 #define NONE 50 -void log(int level,char *text, ...); +/* 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...) do_log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) + +void do_log(int level, const char *text, ...); void readfile(file_cache &F, const char* fname); void Write(int sock,char *text, ...); diff --git a/src/cmd_pong.cpp b/src/cmd_pong.cpp index cc708ee80..76acfbccd 100644 --- a/src/cmd_pong.cpp +++ b/src/cmd_pong.cpp @@ -17,6 +17,7 @@ #include "users.h" #include "commands.h" #include "commands/cmd_pong.h" +#include "helperfuncs.h" void cmd_pong::Handle (char **parameters, int pcnt, userrec *user) { diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp index 8cad4e329..191cecb0f 100644 --- a/src/cmd_topic.cpp +++ b/src/cmd_topic.cpp @@ -21,6 +21,7 @@ #include "message.h" #include "commands.h" #include "commands/cmd_topic.h" +#include "helperfuncs.h" extern ServerConfig* Config; extern int MODCOUNT; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index d0009328c..7c3b8c3ea 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -67,7 +67,7 @@ static time_t LAST = 0; * Write a line of text `text' to the logfile (and stdout, if in nofork) if the level `level' * is greater than the configured loglevel. */ -void log(int level, char *text, ...) +void do_log(int level, const char *text, ...) { va_list argsPtr; char textbuffer[MAXBUF]; diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 976f578fd..886e2b0d0 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -28,6 +28,7 @@ #include <vector> #include <string> #include "socketengine.h" +#include "helperfuncs.h" char ref[MAX_DESCRIPTORS]; |