Author: rfm
Date: Wed Nov 18 12:25:49 2015
New Revision: 39175
URL: http://svn.gna.org/viewcvs/gnustep?rev=39175&view=rev
Log:
Diagnostics for alarms
Modified:
libs/ec/trunk/AlertConfig.plist
libs/ec/trunk/ChangeLog
libs/ec/trunk/EcAlerter.h
libs/ec/trunk/EcAlerter.m
libs/ec/trunk/EcProcess.m
Modified: libs/ec/trunk/AlertConfig.plist
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/AlertConfig.plist?rev=39175&r1=39174&r2=39175&view=diff
==============================================================================
--- libs/ec/trunk/AlertConfig.plist (original)
+++ libs/ec/trunk/AlertConfig.plist Wed Nov 18 12:25:49 2015
@@ -3,6 +3,7 @@
* details on what you can configure here.
*/
Debug = NO; /* Defaults ... do not log email alerts sent */
+ Quiet = NO; /* Defaults ... suppress logging of alarms */
/* If we wish to extend/oeverride the function of the EcAlerter class in
* handling alerts, we may do so by specifying the name of a subclass of
Modified: libs/ec/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=39175&r1=39174&r2=39175&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog (original)
+++ libs/ec/trunk/ChangeLog Wed Nov 18 12:25:49 2015
@@ -1,3 +1,11 @@
+2015-11-18 Richard Frith-Macdonald <[email protected]>
+
+ * EcProcess.m: Improve output when changing/reading defaults, and
+ restore tolerant behavior of doing a read by default.
+ * ECAlerter.h:
+ * ECAlerter.m: Remove obsolete methods, and a 'Quiet' configuration
+ option, and log alarms (and their disposition) by default.
+
2015-11-18 Niels Grewe <[email protected]>
* EcProcess.m: Fix argument validation when reading/writing defaults.
Modified: libs/ec/trunk/EcAlerter.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcAlerter.h?rev=39175&r1=39174&r2=39175&view=diff
==============================================================================
--- libs/ec/trunk/EcAlerter.h (original)
+++ libs/ec/trunk/EcAlerter.h Wed Nov 18 12:25:49 2015
@@ -296,6 +296,9 @@
* <term>Debug</term>
* <desc>A boolean saying whether extra debug data should be logged.
* If YES, all outgoing Email messages are logged.</desc>
+ * <term>Quiet</term>
+ * <desc>A boolean saying whether standard debug logs should be suppressed.
+ * If YES, the handling of alarm messages is not logged.</desc>
* <term>EmailFrom</term>
* <desc>The sender address to use for outgoing alert Email messages.
* By default 'alerter@host' where 'host' is the value defined in
@@ -361,6 +364,7 @@
BOOL debug; /** Debug enabled in config */
BOOL supersede; /** If a clear should replace original */
BOOL eThreaded; /** alarm reminder emails threaded */
+ BOOL quiet; /** Quiet enabled in config */
}
/** Called when user defaults are updated, this fetches the dictionary
@@ -441,10 +445,6 @@
isClear: (BOOL)isClear
to: (NSArray*)destinations;
-/** Calls -log:identifier:isClear:to: with a nil identifier.
- */
-- (void) log: (NSMutableDictionary*)m to: (NSArray*)destinations;
-
/** Called by
* -handleEvent:withHost:andServer:timestamp:identifier:alarm:reminder:
* to pass a message to an array of destinations.
@@ -454,11 +454,6 @@
- (void) mail: (NSMutableDictionary*)m
identifier: (NSString*)identifier
isClear: (BOOL)isClear
- to: (NSArray*)destinations;
-
-/** Calls -mail:identifier:isClear:to: with a nil identifier.
- */
-- (void) mail: (NSMutableDictionary*)m
to: (NSArray*)destinations;
/** Cache a copy of the Rules with modifications to store information
@@ -478,10 +473,6 @@
isClear: (BOOL)isClear
to: (NSArray*)destinations;
-/** Calls -sms:identifier:isClear:to: with a nil identifier.
- */
-- (void) sms: (NSMutableDictionary*)m to: (NSArray*)destinations;
-
/** Responsible for the periodic calling of -flushEmail and -flushSms
*/
- (void) timeout: (NSTimer*)t;
Modified: libs/ec/trunk/EcAlerter.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcAlerter.m?rev=39175&r1=39174&r2=39175&view=diff
==============================================================================
--- libs/ec/trunk/EcAlerter.m (original)
+++ libs/ec/trunk/EcAlerter.m Wed Nov 18 12:25:49 2015
@@ -111,10 +111,24 @@
int duration;
int reminder;
int severity;
+ BOOL isAlarm;
BOOL isClear;
}
+- (NSString*) alarmText;
@end
@implementation EcAlerterEvent
+- (NSString*) alarmText
+{
+ if (NO == isAlarm)
+ {
+ return nil;
+ }
+ if (YES == isClear)
+ {
+ return [identifier stringByAppendingString: @"(clear)"];
+ }
+ return [identifier stringByAppendingString: @"(alarm)"];
+}
- (void) dealloc
{
RELEASE(hostName);
@@ -246,6 +260,7 @@
- (BOOL) configureWithDefaults: (NSDictionary*)c
{
debug = [[c objectForKey: @"Debug"] boolValue];
+ quiet = [[c objectForKey: @"Quiet"] boolValue];
supersede = [[c objectForKey: @"Supersede"] boolValue];
[self _setEFrom: [c objectForKey: @"EmailFrom"]];
ASSIGNCOPY(eHost, [c objectForKey: @"EmailHost"]);
@@ -956,6 +971,10 @@
}
}
[event->m setObject: s forKey: @"Replacement"];
+ if (YES == event->isAlarm && NO == quiet)
+ {
+ NSLog(@"Send Email for %@ to %@", [event alarmText], o);
+ }
[self mail: event->m
identifier: event->identifier
isClear: event->isClear
@@ -1012,6 +1031,10 @@
}
}
[event->m setObject: s forKey: @"Replacement"];
+ if (YES == event->isAlarm && NO == quiet)
+ {
+ NSLog(@"Send Email for %@ to %@", [event alarmText], o);
+ }
[self mail: event->m
identifier: event->identifier
isClear: event->isClear
@@ -1056,6 +1079,10 @@
}
}
[event->m setObject: s forKey: @"Replacement"];
+ if (YES == event->isAlarm && NO == quiet)
+ {
+ NSLog(@"Send SMS for %@ to %@", [event alarmText], o);
+ }
[self sms: event->m
identifier: event->identifier
isClear: event->isClear
@@ -1090,12 +1117,20 @@
if ([[d objectForKey: @"Stop"] boolValue] == YES)
{
+ if (YES == event->isAlarm && NO == quiet)
+ {
+ NSLog(@"Stop %@ with %@", [event alarmText], d);
+ }
break; // Don't want to perform any more matches.
}
}
if (NO == found)
{
- if (YES == debug)
+ if (YES == event->isAlarm && NO == quiet)
+ {
+ NSLog(@"No match of %@ with %@", [event alarmText], rulesArray);
+ }
+ else if (YES == debug)
{
NSLog(@"No match of %@ with %@", event->m, rulesArray);
}
@@ -1129,6 +1164,7 @@
{
event->severity = EcAlarmSeverityIndeterminate;
event->severityText = @"";
+ event->isAlarm = NO;
event->isClear = NO;
if (nil != identifier)
{
@@ -1144,6 +1180,7 @@
event->severity = [alarm perceivedSeverity];
ASSIGN(event->severityText,
[EcAlarm stringFromSeverity: event->severity]);
+ event->isAlarm = YES;
if ([@"Clear" isEqual: [alarm extra]])
{
event->isClear = YES;
@@ -1192,6 +1229,10 @@
[m setObject: event->text forKey: @"Message"];
[m setObject: event->text forKey: @"Original"];
+ if (YES == event->isAlarm && NO == quiet)
+ {
+ NSLog(@"Handling %@ ... %@", [event alarmText], alarm);
+ }
[self applyRules: rules toEvent: event];
}
NS_HANDLER
@@ -1330,11 +1371,6 @@
}
}
-- (void) log: (NSMutableDictionary*)m to: (NSArray*)destinations
-{
- [self log: m identifier: nil isClear: NO to: destinations];
-}
-
- (void) mail: (NSMutableDictionary*)m
identifier: (NSString*)identifier
isClear: (BOOL)isClear
@@ -1550,12 +1586,6 @@
}
}
}
-
-- (void) mail: (NSMutableDictionary*)m to: (NSArray*)destinations
-{
- [self mail: m identifier: nil isClear: NO to: destinations];
-}
-
- (void) sms: (NSMutableDictionary*)m
identifier: (NSString*)identifier
@@ -1611,11 +1641,6 @@
}
}
-- (void) sms: (NSMutableDictionary*)m to: (NSArray*)destinations
-{
- [self sms: m identifier: nil isClear: NO to: destinations];
-}
-
- (void) timeout: (NSTimer*)t
{
[self flushSms];
Modified: libs/ec/trunk/EcProcess.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.m?rev=39175&r1=39174&r2=39175&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.m (original)
+++ libs/ec/trunk/EcProcess.m Wed Nov 18 12:25:49 2015
@@ -3045,28 +3045,19 @@
[cmdDefs setCommand: nil forKey: key];
val = [cmdDefs objectForKey: key];
}
- else if ([msg count] > 2
- && (([mode caseInsensitiveCompare: @"set"] == NSOrderedSame)
- || [mode caseInsensitiveCompare: @"write"] == NSOrderedSame)
- )
- {
- if ([msg count] < 4)
- {
- [self cmdPrintf: @"Missing argument (please provide a value
to write).\n"];
- return;
- }
+ else if ([msg count] > 3
+ && [mode caseInsensitiveCompare: @"set"] == NSOrderedSame)
+ {
val = [msg objectAtIndex: 3];
[cmdDefs setCommand: val forKey: key];
val = [cmdDefs objectForKey: key];
}
- else if ([mode caseInsensitiveCompare: @"read"] == NSOrderedSame)
- {
- val = [cmdDefs objectForKey: key];
- }
else
{
- [self cmdPrintf: @"Invalid subcommand: '%@'\n", mode];
- return;
+ /* To be tolerant of typing errors, anything else is
+ * treated as a 'read'
+ */
+ val = [cmdDefs objectForKey: key];
}
if (val == old || [val isEqual: old])
{
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs