mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-23 03:41:23 +00:00
add some debug
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@38320 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2749de7390
commit
80f1a6fa2c
2 changed files with 72 additions and 9 deletions
|
@ -97,6 +97,7 @@
|
||||||
NSString *_name;
|
NSString *_name;
|
||||||
id<EcAlarmDestination> _destination;
|
id<EcAlarmDestination> _destination;
|
||||||
NSArray *_backups;
|
NSArray *_backups;
|
||||||
|
BOOL _debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Passes an alarm to the destination by adding it to a queue of alarm
|
/** Passes an alarm to the destination by adding it to a queue of alarm
|
||||||
|
@ -172,6 +173,12 @@
|
||||||
*/
|
*/
|
||||||
- (BOOL) setCoalesce: (BOOL)coalesce;
|
- (BOOL) setCoalesce: (BOOL)coalesce;
|
||||||
|
|
||||||
|
/** Sets debug on/off. When debugging is on, we generate logs of
|
||||||
|
* forwarding to the destination and of coalescing of alams.<br />
|
||||||
|
* Returns the previous value of the setting.
|
||||||
|
*/
|
||||||
|
- (BOOL) setDebug: (BOOL)debug;
|
||||||
|
|
||||||
/** Sets the destination to which alarms should be forwarded.<br />
|
/** Sets the destination to which alarms should be forwarded.<br />
|
||||||
* If nil this turns off forwarding until it is re-set to a non-nil
|
* If nil this turns off forwarding until it is re-set to a non-nil
|
||||||
* destination.<br />
|
* destination.<br />
|
||||||
|
|
|
@ -84,19 +84,34 @@
|
||||||
[_alarmQueue addObject: event];
|
[_alarmQueue addObject: event];
|
||||||
if (NSNotFound != index)
|
if (NSNotFound != index)
|
||||||
{
|
{
|
||||||
event = [_alarmQueue objectAtIndex: index];
|
EcAlarm *old = [_alarmQueue objectAtIndex: index];
|
||||||
if ([event perceivedSeverity] == EcAlarmSeverityCleared)
|
|
||||||
|
if ([old perceivedSeverity] == EcAlarmSeverityCleared)
|
||||||
{
|
{
|
||||||
|
if (YES == _debug)
|
||||||
|
{
|
||||||
|
NSLog(@"Coalesce %@ by removing %@", event, old);
|
||||||
|
}
|
||||||
[_alarmQueue removeObjectAtIndex: index];
|
[_alarmQueue removeObjectAtIndex: index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[event retain];
|
NSUInteger index;
|
||||||
[_alarmQueue removeObject: event];
|
|
||||||
|
index = [_alarmQueue indexOfObject: event];
|
||||||
[_alarmQueue addObject: event];
|
[_alarmQueue addObject: event];
|
||||||
[event release];
|
if (NSNotFound != index)
|
||||||
|
{
|
||||||
|
EcAlarm *old = [_alarmQueue objectAtIndex: index];
|
||||||
|
|
||||||
|
if (YES == _debug)
|
||||||
|
{
|
||||||
|
NSLog(@"Coalesce %@ by removing %@", event, old);
|
||||||
|
}
|
||||||
|
[_alarmQueue removeObjectAtIndex: index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[_alarmLock unlock];
|
[_alarmLock unlock];
|
||||||
}
|
}
|
||||||
|
@ -206,8 +221,17 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[_alarmQueue removeObject: event];
|
NSUInteger index = [_alarmQueue indexOfObject: event];
|
||||||
[_alarmQueue addObject: event];
|
|
||||||
|
[_alarmQueue addObject: event];
|
||||||
|
if (NSNotFound != index)
|
||||||
|
{
|
||||||
|
if (YES == _debug)
|
||||||
|
{
|
||||||
|
NSLog(@"Coalesce %@", event);
|
||||||
|
}
|
||||||
|
[_alarmQueue removeObjectAtIndex: index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[_alarmLock unlock];
|
[_alarmLock unlock];
|
||||||
}
|
}
|
||||||
|
@ -292,6 +316,17 @@
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) setDebug: (BOOL)debug
|
||||||
|
{
|
||||||
|
BOOL old;
|
||||||
|
|
||||||
|
[_alarmLock lock];
|
||||||
|
old = _debug;
|
||||||
|
_debug = (YES == debug) ? YES : NO;
|
||||||
|
[_alarmLock unlock];
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
- (id<EcAlarmDestination>) setDestination: (id<EcAlarmDestination>)destination
|
- (id<EcAlarmDestination>) setDestination: (id<EcAlarmDestination>)destination
|
||||||
{
|
{
|
||||||
id old;
|
id old;
|
||||||
|
@ -372,8 +407,17 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[_alarmQueue removeObject: event];
|
NSUInteger index = [_alarmQueue indexOfObject: event];
|
||||||
[_alarmQueue addObject: event];
|
|
||||||
|
[_alarmQueue addObject: event];
|
||||||
|
if (NSNotFound != index)
|
||||||
|
{
|
||||||
|
if (YES == _debug)
|
||||||
|
{
|
||||||
|
NSLog(@"Coalesce %@", event);
|
||||||
|
}
|
||||||
|
[_alarmQueue removeObjectAtIndex: index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[_alarmLock unlock];
|
[_alarmLock unlock];
|
||||||
}
|
}
|
||||||
|
@ -664,6 +708,10 @@
|
||||||
}
|
}
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[[self _connect] alarm: event];
|
[[self _connect] alarm: event];
|
||||||
|
if (YES == _debug)
|
||||||
|
{
|
||||||
|
NSLog(@"%@ %@", NSStringFromSelector(_cmd), event);
|
||||||
|
}
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[[self backups] makeObjectsPerformSelector: @selector(alarm:)
|
[[self backups] makeObjectsPerformSelector: @selector(alarm:)
|
||||||
withObject: event];
|
withObject: event];
|
||||||
|
@ -688,6 +736,10 @@
|
||||||
}
|
}
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[[self _connect] domanage: managedObject];
|
[[self _connect] domanage: managedObject];
|
||||||
|
if (YES == _debug)
|
||||||
|
{
|
||||||
|
NSLog(@"%@ %@", NSStringFromSelector(_cmd), managedObject);
|
||||||
|
}
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[[self backups] makeObjectsPerformSelector: @selector(domanage:)
|
[[self backups] makeObjectsPerformSelector: @selector(domanage:)
|
||||||
withObject: managedObject];
|
withObject: managedObject];
|
||||||
|
@ -712,6 +764,10 @@
|
||||||
}
|
}
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[[self _connect] unmanage: managedObject];
|
[[self _connect] unmanage: managedObject];
|
||||||
|
if (YES == _debug)
|
||||||
|
{
|
||||||
|
NSLog(@"%@ %@", NSStringFromSelector(_cmd), managedObject);
|
||||||
|
}
|
||||||
NS_DURING
|
NS_DURING
|
||||||
[[self backups] makeObjectsPerformSelector: @selector(unmanage:)
|
[[self backups] makeObjectsPerformSelector: @selector(unmanage:)
|
||||||
withObject: managedObject];
|
withObject: managedObject];
|
||||||
|
|
Loading…
Reference in a new issue