Provide a set of unique rules.
More...
Namespaces |
namespace | ball |
Detailed Description
- Outline
-
-
- Purpose:
- Provide a set of unique rules.
-
- Classes:
-
- See also:
- Component ball_rule
-
- Description:
- This component provides a value-semantic container,
ball::RuleSet
, for storage and efficient retrieval of ball::Rule
objects.
- This component participates in the implementation of "Rule-Based Logging". For more information on how to use that feature, please see the package level documentation and usage examples for "Rule-Based Logging".
-
- Thread Safety:
ball::RuleSet
is not thread-safe in that multiple threads attempting to concurrently modify the same ball::RuleSet
object will leave the object in an undefined state. To ensure thread-safety, concurrent accesses to a ball::RuleSet
must be serialized by a mutex.
-
- Usage:
- The following code fragments illustrate how to use a rule set.
- We first create a rule whose pattern is
WEEKEND*
and whose threshold levels are all ball::Severity::e_OFF
except the pass-through
level. A pass-through
level of ball::Severity::e_INFO
indicates that whenever the rule is active and the severity equals or exceeds ball::Severity::e_INFO
, log records will be passed to the observer: Next, we create another rule having a different pattern, but the same threshold levels: We then create a ball::RuleSet
object, add the two rules, and verify that rules were added correctly: Duplicate rules cannot be added: Rules in a rule set can be looked up by the ruleId
method: int i1 = ruleSet.ruleId(rule1);
int i2 = ruleSet.ruleId(rule2);
assert(0 <= i1); assert(i1 < ruleSet.maxNumRules());
assert(0 <= i2); assert(i2 < ruleSet.maxNumRules());
assert(i1 != i2);
The removeRule
method can be used to remove rules from a rule set.