BDE 4.14.0 Production release
|
Provide a suite of utility functions for logging administration.
This component provides a namespace, ball::Administration
, containing a suite of utility functions to facilitate administration of the ball
logging subsystem from a console operator's perspective. Utilities are provided for adding a category to the registry maintained by the singleton instance of ball::LoggerManager
(hereafter the "logger
manager"), for setting the threshold levels of one or more categories, for setting a limit on the maximum number of categories allowed, and for retrieving the threshold levels of (established) categories. Note that a precondition of all of the utility functions is that the logger manager singleton must be initialized and not in the process of being shut down.
This section illustrates intended use of this component.
The code fragments in this example demonstrate several administration utilities that are used to create categories, and to set and access their threshold levels.
First we initialize the logger manager (for the purposes of this example, we use a minimal configuration):
Next define some hypothetical category names:
Category naming is by convention only. In this example, we have chosen a hierarchical naming convention that uses .
to separate the constituents of category names.
In the following, the addCategory
method is used to define a category for each of the category names in equityCategories
. The threshold levels for each of the categories are set to slightly different values to help distinguish them when they are printed later. The addCategory
method returns the address of the new category:
In the following, each of the new categories is accessed from the registry and its name and threshold levels are printed to bsl::cout
:
The following is printed to stdout
:
The following is similar to the first for
-loop above, but this time the setThresholdLevels
method is used to modify the threshold levels of existing categories. The setThresholdLevels
method returns 1 in each case indicating the number of existing categories that were affected by the call:
When the NUM_CATEGORIES
categories are accessed from the registry a second time and printed, the following is output to stdout
showing the new threshold levels of the categories:
Finally, the category registry is closed to further additions by setting its maximum capacity to (the original) NUM_CATEGORIES
:
Following this call to setMaxNumCategories
, subsequent calls to addCategory
will fail (until such time as setMaxNumCategories
is called again with an argument value that is either 0 or is greater than NUM_CATEGORIES
, where 0 indicates the category registry has unlimited capacity).