mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-15 16:11:01 +00:00
clear cached logger objects when necessary
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@38086 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b6f56ee478
commit
086003eb7d
3 changed files with 37 additions and 1 deletions
|
@ -112,5 +112,9 @@
|
|||
|
||||
@end
|
||||
|
||||
/** Notification sent when the logging set of cached loggers is emptied.
|
||||
*/
|
||||
extern NSString* const EcLoggersDidChangeNotification;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
17
EcLogger.m
17
EcLogger.m
|
@ -33,6 +33,9 @@
|
|||
#import "EcProcess.h"
|
||||
#import "EcLogger.h"
|
||||
|
||||
NSString* const EcLoggersDidChangeNotification
|
||||
= @"EcLoggersDidChangeNotification";
|
||||
|
||||
@implementation EcLogger
|
||||
|
||||
static Class loggersClass;
|
||||
|
@ -100,11 +103,25 @@ static NSArray *modes;
|
|||
|
||||
+ (void) setFactory: (Class)c
|
||||
{
|
||||
NSMutableArray *old = nil;
|
||||
|
||||
if (Nil == c) c = [self class];
|
||||
NSAssert([c isSubclassOfClass: self], NSInvalidArgumentException);
|
||||
[loggersLock lock];
|
||||
if (loggersClass != c)
|
||||
{
|
||||
old = loggers;
|
||||
loggers = [NSMutableArray new];
|
||||
loggersClass = c;
|
||||
}
|
||||
[loggersLock unlock];
|
||||
if (nil != old)
|
||||
{
|
||||
[old makeObjectsPerformSelector: @selector(flush)];
|
||||
[old release];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:
|
||||
EcLoggersDidChangeNotification object: self];
|
||||
}
|
||||
}
|
||||
|
||||
/* Should only be called on main thread, but doesn't matter.
|
||||
|
|
15
EcProcess.m
15
EcProcess.m
|
@ -1495,6 +1495,15 @@ static NSString *noFiles = @"No log files to archive";
|
|||
return cmdSignalled;
|
||||
}
|
||||
|
||||
- (void) ecLoggersChanged: (NSNotification*)n
|
||||
{
|
||||
DESTROY(alertLogger);
|
||||
DESTROY(auditLogger);
|
||||
DESTROY(debugLogger);
|
||||
DESTROY(errorLogger);
|
||||
DESTROY(warningLogger);
|
||||
}
|
||||
|
||||
- (NSDate*) ecStarted
|
||||
{
|
||||
return started;
|
||||
|
@ -3814,6 +3823,12 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
|
|||
name: NSUserDefaultsDidChangeNotification
|
||||
object: [NSUserDefaults standardUserDefaults]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(ecLoggersChanged:)
|
||||
name: EcLoggersDidChangeNotification
|
||||
object: nil];
|
||||
|
||||
[self cmdMesgCache];
|
||||
|
||||
[self cmdDefaultsChanged: nil];
|
||||
|
|
Loading…
Reference in a new issue