This class provides a mechanism for associating attributes with the current thread, and evaluating the logging rules associated with a category using those stored attributes. AttributeContext contains class data members that must be initialized (using the initialize class method) with a CategoryManager object containing a RuleSet that represents the currently installed logging rules for the process. Clients can obtain the context for the current thread by calling the getContext class method. The addAttributes and removeAttributes methods are used to add and remove collections of attributes from the (thread‐local) context object. Finally, AttributeContext provides methods (used primarily by other components in the ball package') to determine the effect of the current logging rules on the logging thresholds of a category. The hasRelevantActiveRules method returns true if there are any relevant and active rules that might modify the logging thresholds of the supplied category. A rule is "relevant" if the rule's pattern matches the category's name, and a rule is "active" if all the attributes defined for the rule are satisfied by the current thread's attributes (i.e., Rule::evaluate returns true for the collection of attributes maintained for the current thread by the thread's AttributeContext object). The determineThresholdLevels method returns the logging threshold levels for a category, factoring in any active rules that apply to the category that might override the category's thresholds. The behavior for the hasRelevantActiveRules and determineThresholdLevels methods is undefined unless initialize has been called. Note that, in practice, initialize is called internally when the logger manager singleton is initialized; clients ordinarily should not call initialize directly.
Synopsis
Declared in <ball_attributecontext.h>
class AttributeContext;
Type Aliases
Name |
Description |
Iterator over the attribute containers in an |
Member Functions
Name |
Description |
Add the specified |
|
Clear this object's cache of evaluated rules. Note that this method must be called if an |
|
Return a |
|
Populate the specified |
|
Return |
|
Return |
|
Format this object to the specified output |
|
Remove the specified |
Static Member Functions
Name |
Description |
Return the address of the current thread's attribute context, if such context exists; otherwise, create an attribute context, install it in thread‐local storage, and return the address of the newly created context. Note that this method can be invoked safely even if the |
|
Initialize the static data members of |
|
Return the address of the modifiable |
|
Reset the static data members of |
|
Invoke the specified |
Friends
Name |
Description |
This class implements a proctor that, on its own destruction, will destroy the attribute context of the current thread. Attribute contexts are stored in thread‐local memory. On destruction, objects of this type will deallocate the current thread's attribute context (if one has been created), and set the thread‐local storage pointer to 0. |
Created with MrDocs