|
From: <mic...@us...> - 2003-09-09 07:37:49
|
Update of /cvsroot/log4cocoa/log4cocoa In directory sc8-pr-cvs1:/tmp/cvs-serv12066 Modified Files: L4Logger.h Log Message: The log4* macros are now variadic. If the message is a string, it is assumed to be a format and you can add additional arguments at the end. If the message is not a string, the extra arguments are ignored. I didn't touch the deprecated L4* macros. Index: L4Logger.h =================================================================== RCS file: /cvsroot/log4cocoa/log4cocoa/L4Logger.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- L4Logger.h 16 Jun 2003 15:54:16 -0000 1.6 +++ L4Logger.h 8 Sep 2003 19:14:01 -0000 1.7 @@ -60,28 +60,27 @@ * to do or can't use these macros for some reason. */ -#define L4_LOCATION lineNumber: __LINE__ fileName: __FILE__ methodName: __PRETTY_FUNCTION__ +void log4Log(id object, int line, char *file, char *method, + SEL sel, BOOL isAssertion, BOOL assertion, + id exception, id message, ...); -#define L4LogDebug L4_LOCATION debug -#define L4LogInfo L4_LOCATION info -#define L4LogWarn L4_LOCATION warn -#define L4LogError L4_LOCATION error -#define L4LogFatal L4_LOCATION fatal -#define L4LogAssert L4_LOCATION assert +#define L4_PLAIN(type) self, __LINE__, __FILE__, __PRETTY_FUNCTION__, @selector(lineNumber:fileName:methodName:type:), NO, YES, nil +#define L4_EXCEPTION(type, e) self, __LINE__, __FILE__, __PRETTY_FUNCTION__, @selector(lineNumber:fileName:methodName:type:exception:), NO, YES, e +#define L4_ASSERTION(assertion) self, __LINE__, __FILE__, __PRETTY_FUNCTION__, @selector(lineNumber:fileName:methodName:assert:log:), YES, assertion, nil -#define log4Debug(message) if([[self l4Logger] isDebugEnabled]) [[self l4Logger] L4LogDebug: message] -#define log4Info(message) if([[self l4Logger] isInfoEnabled]) [[self l4Logger] L4LogInfo: message] -#define log4Warn(message) [[self l4Logger] L4LogWarn: message] -#define log4Error(message) [[self l4Logger] L4LogError: message] -#define log4Fatal(message) [[self l4Logger] L4LogFatal: message] +#define log4Debug(message, args...) if([[self l4Logger] isDebugEnabled]) log4Log(L4_PLAIN(debug), message, ## args) +#define log4Info(message, args...) if([[self l4Logger] isInfoEnabled]) log4Log(L4_PLAIN(info), message, ## args) +#define log4Warn(message, args...) log4Log(L4_PLAIN(warn), message, ## args) +#define log4Error(message, args...) log4Log(L4_PLAIN(error), message, ## args) +#define log4Fatal(message, args...) log4Log(L4_PLAIN(fatal), message, ## args) -#define log4DebugWithException(message, e) if([[self l4Logger] isDebugEnabled]) [[self l4Logger] L4LogDebug: message exception: e] -#define log4InfoWithException(message, e) if([[self l4Logger] isInfoEnabled]) [[self l4Logger] L4LogInfo: message exception: e] -#define log4WarnWithException(message, e) [[self l4Logger] L4LogWarn: message exception: e] -#define log4ErrorWithException(message, e) [[self l4Logger] L4LogError: message exception: e] -#define log4FatalWithException(message, e) [[self l4Logger] L4LogFatal: message exception: e] +#define log4DebugWithException(message, e, args...) if([[self l4Logger] isDebugEnabled]) log4Log(L4_EXCEPTION(debug, e), message, ## args) +#define log4InfoWithException(message, e, args...) if([[self l4Logger] isInfoEnabled]) log4Log(L4_EXCEPTION(info, e), message, ## args) +#define log4WarnWithException(message, e, args...) log4Log(L4_EXCEPTION(warn, e), message, ## args) +#define log4ErrorWithException(message, e, args...) log4Log(L4_EXCEPTION(error, e), message, ## args) +#define log4FatalWithException(message, e, args...) log4Log(L4_EXCEPTION(fatal, e), message, ## args) -#define log4Assert(assertion, message) [[self l4Logger] L4LogAssert: assertion log: message] +#define log4Assert(assertion, message, args...) log4Log(L4_ASSERTION(assertion), message, ## args) /***** * NOTE: THESE FOLLOWING MACROS WILL GO AWAY IN 1.0. THEY ARE JUST BEING KEPT AROUND FOR @@ -89,6 +88,15 @@ */ #warning "REMEMBER TO DELETE COMPATIBLITY MACROS IN L4Logger.h" // +#define L4_LOCATION lineNumber: __LINE__ fileName: __FILE__ methodName: __PRETTY_FUNCTION__ + +#define L4LogDebug L4_LOCATION debug +#define L4LogInfo L4_LOCATION info +#define L4LogWarn L4_LOCATION warn +#define L4LogError L4_LOCATION error +#define L4LogFatal L4_LOCATION fatal +#define L4LogAssert L4_LOCATION assert + #define L4Debug(message) if([[self l4Logger] isDebugEnabled]) [[self l4Logger] L4LogDebug: message] #define L4Info(message) if([[self l4Logger] isInfoEnabled]) [[self l4Logger] L4LogInfo: message] #define L4Warn(message) [[self l4Logger] L4LogWarn: message] |