This class is usually a singleton. It provides a factory for Logger objects and is also a wrapper for category administration services. Note that some services provided by this class are available only after the singleton has been initialized.

Synopsis

Declared in <ball_loggermanager.h>

class LoggerManager;

Type Aliases

Name

Description

AttributeCollector

AttributeCollector is the type of a user‐supplied functor used to visit a collection of attributes.

AttributeVisitor

AttributeVisitor is the type of a user‐supplied functor invoked by an attribute collector for every attribute.

CategoryNameFilterCallback

CategoryNameFilterCallback is the type of the user‐supplied functor that translates external category names to internal names.

DefaultThresholdLevelsCallback

DefaultThresholdLevelsCallback is the type of the functor that determines default threshold levels for categories added to the registry by the setCategory(const char *) method.

ObserverRegistry

This typedef is an alias for the type of the internal broadcast observer registry.

PublishAllTriggerCallback

PublishAllTriggerCallback is the type of the functor that is invoked to publish all record buffers of all active loggers (i.e., loggers allocated by the logger manager that have not yet been deallocated).

UserFieldsPopulatorCallback

UserFieldsPopulatorCallback is the type of a user‐supplied callback functor used to populate the user‐defined fields in each log record.

Member Functions

Name

Description

LoggerManager [constructor]

Create a logger manager having the specified configuration of defaults and attributes. Optionally specify a globalAllocator used to supply memory. If globalAllocator is 0, the currently installed global allocator is used. Note that the new logger manager is not the singleton logger manager used by macros of the BALL logging framework.

~LoggerManager [destructor]

Destroy this logger manager.

addCategory

Add to the category registry of this logger manager a new category having the specified categoryName and the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel threshold levels, respectively, if (1) categoryName is not present in the registry, (2) the number of categories in the registry is less than the registry capacity, and (3) each threshold level is in the range [0 .. 255]. Return the address of the new modifiable category on success, and 0 otherwise. The behavior is undefined unless categoryName is null‐terminated.

addCategoryHierarchically

Add a new category having the specified categoryName; return the address of the modifiable new category on success, and 0, with no effect, if a category by that name already exists or if the number of existing categories has reached the maximum capacity. The newly created category will have its threshold levels chosen primarily from two sources: threshold levels of an existing category or a category setting (to which no category exists) choosing the one whose name is the longest non‐empty prefix of categoryName. If such a category or setting exists, and the default threshold levels (which might be overridden by a default threshold levels callback) otherwise. See also ball::CategoryManager::addCategoryHierarchically.

addRule

Add a rule having the specified value to the set of (unique) rules maintained by this object. Return the number of rules added (i.e., 1 on success and 0 if a rule with the same value is already present).

addRules

Add each rule in the specified ruleSet to the set of (unique) rules maintained by this object. Return the number of rules added. Note that each rule having the same value as an existing rule will be ignored.

allocateLogger

allocateLogger overloads

allocator

Return the address of the modifiable allocator held by this logger manager.

deallocateLogger

Deallocate the specified logger and release logger from management by this logger manager. The behavior is undefined unless logger was obtained by invoking the allocateLogger method of this logger manager and logger has not yet been deallocated. Note that this method is intended primarily for multi‐threaded applications.

defaultCategory

defaultCategory overloads

defaultPassThresholdLevel

Return the default pass threshold level of this logger manager.

defaultRecordThresholdLevel

Return the default record threshold level of this logger manager.

defaultThresholdLevels

Return the default threshold levels associated with this logger manager object.

defaultTriggerAllThresholdLevel

Return the default trigger‐all threshold level of this logger manager.

defaultTriggerThresholdLevel

Return the default trigger threshold level of this logger manager.

deregisterAllObservers

Remove all observers from the registry of observers maintained by this logger manager.

deregisterAttributeCollector

Remove the attribute collector having the specified collectorName from the registry of collectors maintained by this logger manager. Return 0 if the collector having collectorName was successfully deregistered from this logger manager, and a non‐zero value (with no effect) otherwise.

deregisterObserver

Remove the observer having the specified observerName from the registry of observers maintained by this logger manager. Return 0 if the observer having observerName was successfully deregistered from this logger manager, and a non‐zero value (with no effect) otherwise. Henceforth, the observer that had observerName will no longer receive log records published by this logger manager.

findObserver

findObserver overloads

getLogger

Return a non‐`const` reference to a logger managed by this logger manager suitable for performing logging operations for this thread of execution.

isCategoryEnabled

Return true if the specified severity is more severe (i.e., is numerically less than) at least one of the threshold levels of the specified category, and false otherwise. If the returned value is false, then a subsequent call to getLogger().logMessage() (with category and severity) will have no effect. This method compares severity with the threshold levels determined by combining category‐>thresholdLevels() with the thresholds provided by any relevant and active logging rules (in ruleSet()) that apply to category. Note that a rule applies to category if the rule's pattern matches category‐>categoryName(), and a rule is active if all the predicates defined for that rule are satisfied by the current thread's attributes (i.e., Rule::evaluate() returns true for the collection of attributes maintained by the current thread's AttributeContext object).

lookupCategory

lookupCategory overloads

maxNumCategories

Return the current capacity of the category registry of this logger manager. A capacity of 0 implies that no limit will be imposed; otherwise, new categories may be added only if numCategories() < maxNumCategories(). Note that 0 < maxNumCategories() < numCategories() is a valid state, implying no new categories may be added.

numCategories

Return the number of categories in the category registry of this logger manager.

observer

observer overloads

publishAll

Transmit to the observers registered with this logger manager all log records accumulated in the record buffers of all loggers managed by this logger manager, and indicate the publication cause to be MANUAL_PUBLISH_ALL.

registerAttributeCollector

Add the specified collector with the specified collectorName to the registry of attribute collectors maintained by this logger manager. Return 0 if collector was successfully registered with this logger manager, and a non‐zero value (with no effect) otherwise. Note that this method will fail if a collector having collectorName is already registered.

registerObserver

Add the specified observer with the specified observerName to the registry of observers maintained by this logger manager. Return 0 if observer was successfully registered with this logger manager, and a non‐zero value (with no effect) otherwise. Henceforth, all log records published by this logger manager are published to this observer, until observer is deregistered. The behavior is undefined if a cyclic reference is created among registered observers. Note that this method will fail if an observer having observerName is already registered.

removeAllRules

Remove every rule from the set of rules maintained by this object.

removeRule

Remove the rule having the specified value from this set of rules maintained by this object. Return the number of rules removed (i.e., 1 on success and 0 if no rule having the same value is found.)

removeRules

Remove each rule in the specified ruleSet from this set of rules maintained by this object. Return the number of rules removed.

resetDefaultThresholdLevels

Reset the default threshold levels of this logger manager to the original "factory‐supplied" default values or the factory overrides supplied at construction.

ruleSet

Return a const reference to the rule set maintained by this object.

setCategory

setCategory overloads

setCategoryThresholdsToCurrentDefaults

Set the threshold levels of the specified category in the category registry of this logger manager to the current default threshold values. The behavior is undefined unless category is non‐null.

setCategoryThresholdsToFactoryDefaults

Set the threshold levels of the specified category in the category registry of this logger manager to the original "factory‐supplied" default values or the factory overrides supplied at construction. The behavior is undefined unless category is non‐null.

setDefaultThresholdLevels

Set the default threshold levels of this logger manager to the specified recordLevel, passLevel, triggerLevel, and triggerAllLevel values, respectively, if each threshold level is in the range [0 .. 255]. Return 0 on success, and a non‐zero value otherwise (with no effect on any default threshold level).

setDefaultThresholdLevelsCallback

Set the default‐thresholds callback of this logger manager to the specified callback. The default‐thresholds callback is used to determine default threshold levels for categories added to the registry by the setCategory(const char *) method.

setLogger

Set the default logger used by this thread of execution to the specified logger, or to the global default logger if logger is 0. The behavior is undefined unless logger was obtained from this logger manager, and this thread of execution does not hold exclusive access to the record buffer of its current default logger.

setMaxNumCategories

Set the capacity of the category registry of this logger manager to the specified length. If length is 0, no limit will be imposed. No categories are removed from the registry if the current number of categories exceeds length. However, subsequent attempts to add categories to the registry will fail. The behavior is undefined unless 0 <= length.

setThresholdLevelsHierarchically

In case the specified categoryNamePrefix is not empty set the threshold levels of every existing and future category whose name has, as a prefix, categoryNamePrefix to the specified threshold values, recordLevel, passLevel, triggerLevel, and triggerAllLevel. In case categoryNamePrefix is empty set the threshold level of every existing category, and remove all preliminary settings (for future categories). Return the number of categories whose threshold levels were set, or a negative value, with no effect, if any of the specified threshold values is outside the range [0 .. 255]. See also ball::CategoryManager::setThresholdLevelsHierarchically.

thresholdLevelsForNewCategory

Load into the specified *levels the threshold levels that would be set for a newly created category, irrespective of whether a category with the specified categoryName is already in the registry. Return 0 on success and a non‐zero value otherwise. If the client has configured a default threshold levels callback (see ball::LoggerManager::DefaultThresholdLevelsCallback in the component doc), the categoryName will be supplied to that callback which will set *levels. Otherwise, if no default threshold levels callback has been provided, the default threshold levels are used. Note that this function will report an error if the callback returns invalid levels. Also note that if a category named categoryName is already in the registry, the levels returned by this method may differ from the levels of that category.

userFieldsPopulatorCallback

Return the address of the non‐modifiable user populator functor registered with this logger manager, or 0 if there is no registered user populator functor.

visitCategories

visitCategories overloads

visitObservers

visitObservers overloads

Static Member Functions

Name

Description

createLoggerManager

createLoggerManager overloads

getRecord

Return the address of a modifiable record with the specified fileName and lineNumber attributes, and whose memory is supplied by the currently installed default allocator. Note that the returned Record must subsequently be supplied to a call to the LoggerManager::logMessage method.

initSingleton

initSingleton overloads

isInitialized

Return true if the logger manager singleton exists, and false otherwise.

logMessage

Publish the specified record using bsls::Log::platformDefaultMessageHandler after setting its severity attribute to the specified severity, and dispose of record. The behavior is undefined unless record was obtained by a call to the LoggerManager::getRecord method. Note that record will be invalid after this method returns.

obtainMessageBuffer

obtainMessageBuffer overloads

shutDownSingleton

Destroy the logger manager singleton and release all resources used by it. This method has no effect if the logger manager singleton does not exist (i.e., it has not been initialized or has already been destroyed). The behavior is undefined if this method is called from one thread while another thread is accessing the logger manager singleton (i.e., this method is not thread‐safe).

singleton

Return a non‐`const` reference to the logger manager singleton. The behavior is undefined unless the logger manager singleton exists.

Friends

Name

Description

BloombergLP::ball::LoggerManagerCategoryManip

This class defines an iterator providing sequential, modifiable access to the categories in the registry of a logger manager's category manager. The order of the iteration is undefined.

BloombergLP::ball::LoggerManagerCategoryIter

This class defines an iterator providing sequential, read‐only access to the categories in the registry of a logger manager's category manager. The order of the iteration is undefined.

Created with MrDocs