From 7c0a77920db0d64c1a3c0f1413fd64c62ae8cefa Mon Sep 17 00:00:00 2001 From: om Date: Thu, 29 Jun 2006 08:30:25 +0000 Subject: Change log() to a #define, the real symbol is now do_log(), the new macro auto-prefixes all log messages with the file and line number where log() was called - should be nice for debugging and telling wtf is coming from what.Currently uses a (probably very standard) g++ extension to make the macro work. Shouldn't be an issue. You must make clean and rebuild all of insp. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4081 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/helperfuncs.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include/helperfuncs.h') 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, ...); -- cgit v1.2.3