diff --git a/EcAlerter.h b/EcAlerter.h
index 4801448..f0c11d3 100644
--- a/EcAlerter.h
+++ b/EcAlerter.h
@@ -116,6 +116,17 @@
* them to a nice readable version, and also match a default rule to
* log full details to the technical team.
*
+ * Tag
+ * Specifies a tag to be associated with this event during execution
+ * of any subsequent rules (until/unless the event is re-tagged).
+ * The tag actually associated with the event is obtained by treating
+ * the tag value as a template and substituting in any values (as for
+ * the Replace and Rewrite fields).
+ *
+ * Tagged
+ * The message is matched if (and only if) it has been tagged
+ * with a value exactly equal to the value of this field.
+ *
* Flush
* A boolean (YES or NO) saying whether stored messages due to
* be sent out later should be sent out immediately after processing
diff --git a/EcAlerter.m b/EcAlerter.m
index 0c88b4c..ca14cbb 100644
--- a/EcAlerter.m
+++ b/EcAlerter.m
@@ -478,6 +478,13 @@ replaceFields(NSDictionary *fields, NSString *template)
RELEASE(pool);
pool = [NSAutoreleasePool new];
d = [rules objectAtIndex: i];
+
+ s = [d objectForKey: @"Tagged"];
+ if (s != nil && NO == [s isEqual: [m objectForKey: @"Tag"]])
+ {
+ continue; // Not a match.
+ }
+
s = [d objectForKey: @"Type"];
if (s != nil && [s isEqualToString: type] == NO)
{
@@ -573,10 +580,15 @@ replaceFields(NSDictionary *fields, NSString *template)
[m setObject: s forKey: @"Message"];
}
- /* Remove any old Replacement setting ... will set up specifically
- * for the output alert type later.
+ /* Set the tag for this event if necessary ... done *after*
+ * all matching, but before sending out the alerts.
*/
- [m removeObjectForKey: @"Replacement"];
+ if (nil != [d objectForKey: @"Tag"])
+ {
+ NSString *s = replaceFields(m, [d objectForKey: @"Tag"]);
+
+ [m setObject: s forKey: @"Tag"];
+ }
NS_DURING
{
@@ -614,6 +626,7 @@ replaceFields(NSDictionary *fields, NSString *template)
localException);
}
NS_ENDHANDLER
+ [m removeObjectForKey: @"Replacement"];
NS_DURING
{
@@ -659,6 +672,7 @@ replaceFields(NSDictionary *fields, NSString *template)
localException);
}
NS_ENDHANDLER
+ [m removeObjectForKey: @"Replacement"];
NS_DURING
{
@@ -731,6 +745,7 @@ replaceFields(NSDictionary *fields, NSString *template)
localException);
}
NS_ENDHANDLER
+ [m removeObjectForKey: @"Replacement"];
[m removeObjectForKey: @"EmailIdentifier"];
[m removeObjectForKey: @"EmailInReplyTo"];
@@ -772,6 +787,7 @@ replaceFields(NSDictionary *fields, NSString *template)
localException);
}
NS_ENDHANDLER
+ [m removeObjectForKey: @"Replacement"];
s = [d objectForKey: @"Flush"];
if (s != nil)