Improve subjects for alarms/clears

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@36486 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-04-07 11:38:46 +00:00
parent ec7e2cf336
commit 69c31c4924
3 changed files with 30 additions and 19 deletions

View file

@ -29,22 +29,32 @@
Rewrite = "{Original}\n\nAlarm outstanding for {Hours} hours.";
},
{
SeverityText = "..*"; /* Any alert with an alarm severity */
SeverityText = "..*";
DurationBelow = "60"; /* Alarm outstanding for under an hour */
Rewrite = "{Original}\n\nAlarm outstanding for {Minutes} minutes.";
},
{
SeverityText = "..*";
Subject = "Alarm {Identifier}";
Email = (
"myaccount@localhost.localdomain"
);
Stop = YES; /* Don't go on to any general alerts */
},
{
SeverityCode = "5"; /* Any alert for a cleared alarm */
DurationAbove = "59"; /* Alarm outstanding for an hour or more */
Rewrite = "{Original}\n\nCleared after {Hours} hours.";
},
{
SeverityCode = "5"; /* Any alert for a cleared alarm */
SeverityCode = "5";
DurationBelow = "60"; /* Alarm outstanding for under an hour */
Rewrite = "{Original}\n\nCleared after {Minutes} minutes.";
},
{
SeverityText = "..*"; /* Any alert with an alarm severity */
SeverityText = "5";
Subject = "Clear {Identifier}";
Email = (
"myaccount@localhost.localdomain"
);

View file

@ -200,10 +200,12 @@
* </p>
* <p>The <em>Email</em> array lists email addresses to which email alerts are
* to be sent.<br />
* An optional 'Subject' field may be present in the rule ... this is used
* to specify that the is to be tagged with the given subject line. This
* <em>defeats</em> batching of messages in that only messages with the
* same subject may be batched in the same email.
* An optional <em>Subject</em> field may be present in the rule ...
* this is used to specify that the is to be tagged with the given
* subject line. This <em>defeats</em> batching of messages in that
* only messages with the same subject may be batched in the same email.<br />
* NB. The value of the <em>Subject</em> field is used as a template
* in the same way as the <em>Replacement</em> fields.
* </p>
*
* <p>Configuration of the alerter is done by the 'Alerter' key in the user

View file

@ -98,11 +98,11 @@
@end
static NSMutableString *
replaceFields(NSDictionary *fields)
replaceFields(NSDictionary *fields, NSString *template)
{
NSMutableString *m;
m = [[[fields objectForKey: @"Replacement"] mutableCopy] autorelease];
m = [[template mutableCopy] autorelease];
if (nil != m)
{
NSEnumerator *e;
@ -541,8 +541,7 @@ replaceFields(NSDictionary *fields)
s = [d objectForKey: @"Rewrite"];
if (nil != s)
{
[m setObject: s forKey: @"Replacement"];
s = replaceFields(m);
s = replaceFields(m, s);
[m setObject: s forKey: @"Message"];
}
@ -816,7 +815,7 @@ replaceFields(NSDictionary *fields)
/*
* Perform {field-name} substitutions ...
*/
s = replaceFields(m);
s = replaceFields(m, [m objectForKey: @"Replacement"]);
while ((d = [e nextObject]) != nil)
{
[[EcProc cmdLogFile: d] printf: @"%@\n", s];
@ -838,6 +837,11 @@ replaceFields(NSDictionary *fields)
NSString *text;
NSString *subject;
/*
* Perform {field-name} substitutions ...
*/
text = replaceFields(m, [m objectForKey: @"Replacement"]);
subject = [m objectForKey: @"Subject"];
if (nil == subject)
{
@ -859,15 +863,10 @@ replaceFields(NSDictionary *fields)
}
else
{
AUTORELEASE(RETAIN(subject));
subject = replaceFields(m, subject);
[m removeObjectForKey: @"Subject"];
}
/*
* Perform {field-name} substitutions ...
*/
text = replaceFields(m);
/* If we need to send immediately, don't buffer the message.
*/
if (nil != identifier)
@ -996,7 +995,7 @@ replaceFields(NSDictionary *fields)
*/
t = RETAIN([m objectForKey: @"Timestamp"]);
[m removeObjectForKey: @"Timestamp"];
s = replaceFields(m);
s = replaceFields(m, [m objectForKey: @"Replacement"]);
if (t != nil)
{
[m setObject: t forKey: @"Timestamp"];