BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball_category

Detailed Description

Outline

Purpose

Provide a container for a name and associated thresholds.

Classes

See also
ball_categorymanager

Description

This component primarily provides a class, ball::Category, used to describe the properties of a logging category. A ball::Category provides access to the category name and the 4 logging threshold levels associated with a category (see ball_loggermanager for a description of the purpose of the various thresholds).

ball "Private" Methods and Classes

This component provides classes that are not intended for use by the users of the ball logging sub-system: ball::CategoryHolder and ball::CategoryManagerImpUtil. These classes are defined in this component because they are either friends of ball::Category or have a circular definition with ball::Category. They are used within the logging sub-system to efficiently process log records.

ball::CategoryHolder

A ball::CategoryHolder is a statically-initializable pointer to a log category. It is designed to work with the logging macros provided by ball (see {ball_log}), and provide a static cache of the log category at the point where a log macro is invoked.

ball::CategoryManagerImpUtil

A ball::CategoryManagerImpUtil provides a suite of utility functions used in creating a manager for log categories (see ball_categorymanager ). A ball::Category object maintains private state that is accessed and manipulated via this utility. Each ball::Category contains private data members that provide:

Usage

This section illustrates intended use of this component.

Example 1: Basic Use of ball::Category

The following example demonstrates creating a category and accessing its threshold information.

Note that other components in the logging subsystem provide more user focused examples of using categories (see ball_loggermanager , ball_administration , and ball_categorymanager ).

First we create a simple category, example, that has the record-level, trigger-level, and trigger-all thresholds set to OFF and the pass-level set to WARN, and verify these values:

ball::Category example("example",
assert(0 == bsl::strcmp("example", example.categoryName());
assert(ball::Severity::e_OFF == example.recordLevel());
assert(ball::Severity::e_WARN == example.passLevel());
assert(ball::Severity::e_OFF == example.triggerLevel());
assert(ball::Severity::e_OFF == example.triggerAllLevel());
Definition ball_category.h:184
@ e_OFF
Definition ball_severity.h:168
@ e_WARN
Definition ball_severity.h:171

See ball_loggermanager for more information on the use of various thresholds levels.

Finally, we test if a the category is enabled for log record recorded with e_ERROR severity:

if (example.isEnabled(ball::Severity::e_ERROR)) {
// publish record
}
@ e_ERROR
Definition ball_severity.h:170