From bf127ecc18e8a53f1e3d77bb7bae4d33f5419423 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 18 Nov 2009 23:13:44 +0000 Subject: [PATCH] Monotone-Parent: 3053345e3004d3568a69d34023dc2bdf34c4c3b4 Monotone-Revision: a1ad485763dbb256f42488a0cf3e8c8061604d83 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-18T23:13:44 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++++++++ Main/SOGo.m | 50 ++++++++++++++++++++++++++------------------------ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a5ea7823..c6e325c4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-11-18 Wolfgang Sourdeau + + * Main/SOGo.m (+initialize): removed the "debugObjectAllocation" global + variable since "debugLeaks" has the same meaning. Instantiate a + "SOGoStartupLogger" object in order to avoid using NSLog when the + parent process is starting, in order to work-around the caching of + the pid in NSLog. + 2009-11-16 Wolfgang Sourdeau * SoObjects/SOGo/SOGoCache.m: "cache", "users" and "localCache" diff --git a/Main/SOGo.m b/Main/SOGo.m index fab8497c0..d15342cec 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -60,51 +60,56 @@ #import "SOGo.h" +@interface SOGoStartupLogger : NSObject +@end + +@implementation SOGoStartupLogger +@end + @implementation SOGo static unsigned int vMemSizeLimit = 0; static BOOL doCrashOnSessionCreate = NO; static BOOL hasCheckedTables = NO; static BOOL debugRequests = NO; -static BOOL debugLeaks = NO; static BOOL useRelativeURLs = NO; static BOOL trustProxyAuthentication; #ifdef GNUSTEP_BASE_LIBRARY -static BOOL debugObjectAllocation = NO; +static BOOL debugLeaks = NO; #endif + (void) initialize { - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *ud; SoClassSecurityInfo *sInfo; NSArray *basicRoles; + SOGoStartupLogger *logger; id tmp; - NSLog(@"starting SOGo (build %@)", SOGoBuildDate); + logger = [SOGoStartupLogger new]; + [logger logWithFormat: @"starting SOGo (build %@)", SOGoBuildDate]; - if ([[ud persistentDomainForName: @"sogod"] count] == 0) - NSLog(@"WARNING: No configuration found. SOGo will not work properly."); - + ud = [NSUserDefaults standardUserDefaults]; + if ([[ud persistentDomainForName: @"sogod"] count] == 0) + [logger warnWithFormat: @"No configuration found." + @" SOGo will not work properly."]; + doCrashOnSessionCreate = [ud boolForKey:@"SOGoCrashOnSessionCreate"]; -#ifdef GNUSTEP_BASE_LIBRARY - debugObjectAllocation = [ud boolForKey: @"SOGoDebugObjectAllocation"]; - if (debugObjectAllocation) - { - NSLog (@"activating stats on object allocation"); - GSDebugAllocationActive (YES); - } -#endif debugRequests = [ud boolForKey: @"SOGoDebugRequests"]; +#ifdef GNUSTEP_BASE_LIBRARY debugLeaks = [ud boolForKey: @"SOGoDebugLeaks"]; + if (debugLeaks) + [logger logWithFormat: @"activating leak debugging"]; +#endif /* vMem size check - default is 384MB */ - + tmp = [ud objectForKey: @"SxVMemLimit"]; vMemSizeLimit = ((tmp != nil) ? [tmp intValue] : 384); if (vMemSizeLimit > 0) - NSLog(@"Note: vmem size check enabled: shutting down app when " - @"vmem > %d MB", vMemSizeLimit); + [logger logWithFormat: @"vmem size check enabled: shutting down app when " + @"vmem > %d MB", vMemSizeLimit]; #if LIB_FOUNDATION_LIBRARY if ([ud boolForKey:@"SOGoEnableDoubleReleaseCheck"]) [NSAutoreleasePool enableDoubleReleaseCheck: YES]; @@ -127,6 +132,7 @@ static BOOL debugObjectAllocation = NO; trustProxyAuthentication = [ud boolForKey: @"SOGoTrustProxyAuthentication"]; useRelativeURLs = [ud boolForKey: @"WOUseRelativeURLs"]; + [logger release]; } - (id) init @@ -337,10 +343,6 @@ static BOOL debugObjectAllocation = NO; { id obj; -#ifdef GNUSTEP_BASE_LIBRARY - if (debugObjectAllocation) - NSLog(@"objects allocated\n%s", GSDebugAllocationList (YES)); -#endif /* put locale info into the context in case it's not there */ [self _setupLocaleInContext:_ctx]; @@ -399,8 +401,6 @@ static BOOL debugObjectAllocation = NO; @"terminating app, vMem size limit (%d MB) has been reached" @" (currently %d MB)", vMemSizeLimit, vmem]; -// if (debugObjectAllocation) -// [self _dumpClassAllocation]; [self terminate]; } } @@ -421,6 +421,7 @@ static BOOL debugObjectAllocation = NO; } cache = [SOGoCache sharedCache]; +#ifdef GNUSTEP_BASE_LIBRARY if (debugLeaks) { if (debugOn) @@ -431,6 +432,7 @@ static BOOL debugObjectAllocation = NO; GSDebugAllocationActive (YES); } } +#endif resp = [super dispatchRequest: _request]; [cache killCache];