BDE 4.14.0 Production release
|
Provide an object having a pattern, thresholds, and attributes.
This component implements a type, ball::Rule
, that consists of a pattern, four threshold levels, and a set of attributes. The pattern indicates the names of the categories for which the rule will become relevant. The four threshold levels determine what actions will be performed on log records when their severity level equals or exceeds any of these threshold levels. The attribute set is a collection of unique attribute name/value pairs.
Note that multiple attributes with the same name are permitted so long as they correspond to different values.
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".
The following code fragments illustrate how to create a rule and add attributes.
We 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 is equal to or exceeds ball::Severity::e_INFO
, log records will be passed to the observer:
Create some attributes and then add one to the rule:
Attributes can be looked up by the hasAttribute
method:
We then add the other attribute:
Attributes can also be removed from the rule by the removeAttribute
method:
The pattern of a rule can be changed by the setPattern
method:
The threshold levels of a rule can also be modified by the setLevels
method: