New methods for improved control of debug

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17245 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-07-17 09:20:27 +00:00
parent a2309a4051
commit f64a32dbd1
3 changed files with 49 additions and 2 deletions

View file

@ -5,6 +5,9 @@
* configure.ac: Check for nanosleep()
* Headers/Foundation/config.h.in: Add entry for nanosleep
* Source/NSThread.m: Use nanosleep if available.
* Headers/Foundation/NSProcessInfo.h: Added new methods -
([-setDebugLoggingEnabled:]) and ([-debugLoggingEnabled])
* Source/NSProcessInfo.m: ditto
2003-07-16 David Ayers <d.ayers@inode.at>

View file

@ -78,7 +78,9 @@ enum {
#ifndef NO_GNUSTEP
@interface NSProcessInfo (GNUstep)
- (BOOL) debugLoggingEnabled;
- (NSMutableSet*) debugSet;
- (void) setDebugLoggingEnabled: (BOOL)flag;
- (BOOL) setLogFile: (NSString*)path;
+ (void) initializeWithArguments: (char**)argv
count: (int)argc

View file

@ -909,6 +909,9 @@ int main(int argc, char *argv[], char *env[])
@end
@implementation NSProcessInfo (GNUstep)
static BOOL debugTemporarilyDisabled = NO;
/**
* Fallback method. The developer must call this method to initialize
* the NSProcessInfo system if none of the system-specific hacks to
@ -923,6 +926,23 @@ int main(int argc, char *argv[], char *env[])
[gnustep_global_lock unlock];
}
/**
* Returns a indication of whether debug logging is enabled.
* This returns YES unless a call to -setDebugLoggingEnabled: has
* been used to turn logging off.
*/
- (BOOL) debugLoggingEnabled
{
if (debugTemporarilyDisabled == YES)
{
return NO;
}
else
{
return YES;
}
}
/**
* This method returns a set of debug levels set using the
* --GNU-Debug=... command line option.<br />
@ -935,6 +955,22 @@ int main(int argc, char *argv[], char *env[])
return _debug_set;
}
/**
* This method permits you to turn all debug logging on or off
* without modifying the set of debug levels in use.
*/
- (void) setDebugLoggingEnabled: (BOOL)flag
{
if (flag == NO)
{
debugTemporarilyDisabled = YES;
}
else
{
debugTemporarilyDisabled = NO;
}
}
/**
* Set the file to which NSLog output should be directed.<br />
* Returns YES on success, NO on failure.<br />
@ -960,14 +996,20 @@ int main(int argc, char *argv[], char *env[])
@end
/**
* Function for rapid testing to see if a debug level is set.
* This is used by the debugging macros.
* Function for rapid testing to see if a debug level is set.<br />
* This is used by the debugging macros.<br />
* If debug logging has been turned off, this returns NO even if
* the specified level exists in the set of debug levels.
*/
BOOL GSDebugSet(NSString *level)
{
static IMP debugImp = 0;
static SEL debugSel;
if (debugTemporarilyDisabled == YES)
{
return NO;
}
if (debugImp == 0)
{
debugSel = @selector(member:);