From f64a32dbd181795e9fd00bd2e4b8aca6e7d49308 Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Thu, 17 Jul 2003 09:20:27 +0000 Subject: [PATCH] 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 --- ChangeLog | 3 ++ Headers/gnustep/base/NSProcessInfo.h | 2 ++ Source/NSProcessInfo.m | 46 ++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 791bd87e7..72f8ad207 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/Headers/gnustep/base/NSProcessInfo.h b/Headers/gnustep/base/NSProcessInfo.h index 077043c14..95e7aeb2a 100644 --- a/Headers/gnustep/base/NSProcessInfo.h +++ b/Headers/gnustep/base/NSProcessInfo.h @@ -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 diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 23fa8cb0c..6e32d83d6 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -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.
@@ -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.
* Returns YES on success, NO on failure.
@@ -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.
+ * This is used by the debugging macros.
+ * 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:);