Add macros to warn once ... eg for deprecated methods/functions.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19395 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2004-05-24 16:08:03 +00:00
parent 8b46caf9ad
commit 1260b16a5a
2 changed files with 36 additions and 0 deletions

View file

@ -2,6 +2,9 @@
* Source/NSDate.m: Implement -hash for abstract class and for the
concrete subclasses as suggested by Marcus Muller.
* Headers/Foundation/NSDebug.h: Add GSOnceFLog() and GSOnceMLog()
to log messages the first time the code is executed ... typical
usage is to log warnings about deprecated features.
2004-05-21 Adam Fedor <fedor@gnu.org>

View file

@ -341,6 +341,39 @@ GS_EXPORT BOOL NSDeallocateZombies;
#define NSDebugMRLog(object, msg)
#endif
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a function. Pass an NSString as a format,
* followed by zero or more arguments for the format string.
* Example: GSOnceMLog(@"This function is deprecated, use another");
*/
#define GSOnceFLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *fmt = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
beenHere = YES; \
NSLog(fmt , ## args); }} while (0)
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a method. Pass an NSString as a format
* followed by zero or more arguments for the format string.<br />
* Example: GSOnceMLog(@"This method is deprecated, use another");
*/
#define GSOnceMLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *fmt = GSDebugMethodMsg( \
self, _cmd, __FILE__, __LINE__, format); \
beenHere = YES; \
NSLog(fmt , ## args); }} while (0)
#ifdef GSWARN