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
: [ EQ, 192, 96, 64, 32 ]
[ EQ.MARKET, 193, 97, 65, 33 ]
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: [ EQ, 192, 96, 64, 32 ]
[ EQ.MARKET, 193, 97, 65, 33 ]
[ EQ.MARKET.NYSE, 193, 97, 65, 33 ]
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: [ EQ, 192, 96, 64, 32 ]
[ EQ.MARKET, 194, 98, 66, 34 ]
[ EQ.MARKET.NYSE, 194, 98, 66, 34 ]