BDE 4.14.0 Production release
|
Provide a suite of utility functions for category management.
This component defines a struct
, ball::LoggerCategoryUtil
, that provides a set of utility functions for managing the categories contained in a ball::LoggerManager
based on the notion of hierarchy. In particular, the setThresholdLevelsHierarchically
function modifies the threshold levels of each category in ball::LoggerManager
whose name has the specified string as a prefix. The addCategoryHierarchically
function creates a new category that inherits threshold levels from the exiting category whose name is the longest prefix match, if such a category exists.
The setThresholdLevels
function is deprecated in favor of setThresholdLevelsHierarchically
. The former is data-sensitive in the sense that the *
located at the end of the specified category name will be treated as a special flag to turn on the prefix name matching, thus causing trouble for categories whose name ends with *
.
This section illustrates intended use of this component.
The following code fragments illustrate basic usage of this component's setThresholdLevelsHierarchically
and addCategoryHierarchically
methods.
First, we create two auxiliary functions that serve to print out the names and threshold level values of all the categories currently in the logger manager singleton:
Now, we set the default threshold levels of the logger manager object to [191, 95, 63, 31] (for brevity, the initialization of the logger manager singleton is elided):
Then, we create two new categories, "EQ" and "EQ.MARKET", by calling the addCategory
method of the logger manager class, with their threshold levels explicitly set to different values (which are also different from the default threshold levels):
The following is printed out by printAllCategories
:
Next, we add a new category using addCategoryHierarchically
:
The new category with name "EQ.MARKET.NYSE" inherits its threshold levels from the category "EQ.MARKET" rather than having the default threshold levels or inheriting them from "EQ" because of the longest prefix matching rule:
Then, we adjust the threshold levels for all categories whose name starts with "EQ.MARKET" using setThresholdLevelsHierarchically
:
We will notice that the threshold levels of "EQ.MARKET" and "EQ.MARKET.NYSE" have been changed to the new values, while those of "EQ" remain unchanged: