[#BloombergLP-ball-LoggerManager]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::LoggerManager
:relfileprefix: ../../
:mrdocs:

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

== Synopsis

Declared in `&lt;ball&lowbar;loggermanager&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class LoggerManager;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/LoggerManager/AttributeCollector.adoc[`AttributeCollector`] 
| `AttributeCollector` is the type of a user&hyphen;supplied functor used to visit a collection of attributes&period;
| xref:BloombergLP/ball/LoggerManager/AttributeVisitor.adoc[`AttributeVisitor`] 
| `AttributeVisitor` is the type of a user&hyphen;supplied functor invoked by an attribute collector for every attribute&period;
| xref:BloombergLP/ball/LoggerManager/CategoryNameFilterCallback.adoc[`CategoryNameFilterCallback`] 
| `CategoryNameFilterCallback` is the type of the user&hyphen;supplied functor that translates external category names to internal names&period;
| xref:BloombergLP/ball/LoggerManager/DefaultThresholdLevelsCallback.adoc[`DefaultThresholdLevelsCallback`] 
| `DefaultThresholdLevelsCallback` is the type of the functor that determines default threshold levels for categories added to the registry by the `setCategory(const char &ast;)` method&period;
| xref:BloombergLP/ball/LoggerManager/ObserverRegistry.adoc[`ObserverRegistry`] 
| This `typedef` is an alias for the type of the internal broadcast observer registry&period;
| xref:BloombergLP/ball/LoggerManager/PublishAllTriggerCallback.adoc[`PublishAllTriggerCallback`] 
| `PublishAllTriggerCallback` is the type of the functor that is invoked to publish all record buffers of all active loggers (i&period;e&period;, loggers allocated by the logger manager that have not yet been deallocated)&period;
| xref:BloombergLP/ball/LoggerManager/UserFieldsPopulatorCallback-05.adoc[`UserFieldsPopulatorCallback`] 
| `UserFieldsPopulatorCallback` is the type of a user&hyphen;supplied callback functor used to populate the user&hyphen;defined fields in each log record&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/LoggerManager/2constructor.adoc[`LoggerManager`]         [.small]#[constructor]#
| Create a logger manager having the specified `configuration` of defaults and attributes&period; Optionally specify a `globalAllocator` used to supply memory&period; If `globalAllocator` is 0, the currently installed global allocator is used&period; Note that the new logger manager is _not_ the singleton logger manager used by macros of the BALL logging framework&period;
| xref:BloombergLP/ball/LoggerManager/2destructor.adoc[`&#126;LoggerManager`] [.small]#[destructor]#
| Destroy this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/addCategory.adoc[`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 `&lsqb;0 &period;&period; 255&rsqb;`&period; Return the address of the new modifiable category on success, and 0 otherwise&period; The behavior is undefined unless `categoryName` is null&hyphen;terminated&period;
| xref:BloombergLP/ball/LoggerManager/addCategoryHierarchically.adoc[`addCategoryHierarchically`] 
| Add a new category having the specified `categoryName`&semi; 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&period; The newly created category will have its threshold levels chosen primarily from two sources&colon; threshold levels of an existing category or a category setting (to which no category exists) choosing the one whose name is the longest non&hyphen;empty prefix of `categoryName`&period; If such a category or setting exists, and the default threshold levels (which might be overridden by a default threshold levels callback) otherwise&period; See also `ball&colon;&colon;CategoryManager&colon;&colon;addCategoryHierarchically`&period;
| xref:BloombergLP/ball/LoggerManager/addRule.adoc[`addRule`] 
| Add a rule having the specified `value` to the set of (unique) rules maintained by this object&period; Return the number of rules added (i&period;e&period;, 1 on success and 0 if a rule with the same value is already present)&period;
| xref:BloombergLP/ball/LoggerManager/addRules.adoc[`addRules`] 
| Add each rule in the specified `ruleSet` to the set of (unique) rules maintained by this object&period; Return the number of rules added&period; Note that each rule having the same value as an existing rule will be ignored&period;
| xref:BloombergLP/ball/LoggerManager/allocateLogger-0e.adoc[`allocateLogger`] 
| `allocateLogger` overloads
| xref:BloombergLP/ball/LoggerManager/allocator.adoc[`allocator`] 
| Return the address of the modifiable allocator held by this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/deallocateLogger.adoc[`deallocateLogger`] 
| Deallocate the specified `logger` and release `logger` from management by this logger manager&period; The behavior is undefined unless `logger` was obtained by invoking the `allocateLogger` method of this logger manager and `logger` has not yet been deallocated&period; Note that this method is intended primarily for multi&hyphen;threaded applications&period;
| xref:BloombergLP/ball/LoggerManager/defaultCategory-05.adoc[`defaultCategory`] 
| `defaultCategory` overloads
| xref:BloombergLP/ball/LoggerManager/defaultPassThresholdLevel.adoc[`defaultPassThresholdLevel`] 
| Return the default pass threshold level of this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/defaultRecordThresholdLevel.adoc[`defaultRecordThresholdLevel`] 
| Return the default record threshold level of this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/defaultThresholdLevels.adoc[`defaultThresholdLevels`] 
| Return the default threshold levels associated with this logger manager object&period;
| xref:BloombergLP/ball/LoggerManager/defaultTriggerAllThresholdLevel.adoc[`defaultTriggerAllThresholdLevel`] 
| Return the default trigger&hyphen;all threshold level of this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/defaultTriggerThresholdLevel.adoc[`defaultTriggerThresholdLevel`] 
| Return the default trigger threshold level of this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/deregisterAllObservers.adoc[`deregisterAllObservers`] 
| Remove all observers from the registry of observers maintained by this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/deregisterAttributeCollector.adoc[`deregisterAttributeCollector`] 
| Remove the attribute collector having the specified `collectorName` from the registry of collectors maintained by this logger manager&period; Return 0 if the collector having `collectorName` was successfully deregistered from this logger manager, and a non&hyphen;zero value (with no effect) otherwise&period;
| xref:BloombergLP/ball/LoggerManager/deregisterObserver.adoc[`deregisterObserver`] 
| Remove the observer having the specified `observerName` from the registry of observers maintained by this logger manager&period; Return 0 if the observer having `observerName` was successfully deregistered from this logger manager, and a non&hyphen;zero value (with no effect) otherwise&period; Henceforth, the observer that had `observerName` will no longer receive log records published by this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/findObserver-0f.adoc[`findObserver`] 
| `findObserver` overloads
| xref:BloombergLP/ball/LoggerManager/getLogger.adoc[`getLogger`] 
| Return a non&hyphen;`const` reference to a logger managed by this logger manager suitable for performing logging operations for this thread of execution&period;
| xref:BloombergLP/ball/LoggerManager/isCategoryEnabled.adoc[`isCategoryEnabled`] 
| Return `true` if the specified `severity` is more severe (i&period;e&period;, is numerically less than) at least one of the threshold levels of the specified `category`, and `false` otherwise&period; If the returned `value` is `false`, then a subsequent call to `getLogger()&period;logMessage()` (with `category` and `severity`) will have no effect&period; This method compares `severity` with the threshold levels determined by combining `category&hyphen;&gt;thresholdLevels()` with the thresholds provided by any relevant and active logging rules (in `ruleSet()`) that apply to `category`&period; Note that a rule applies to `category` if the rule&apos;s pattern matches `category&hyphen;&gt;categoryName()`, and a rule is active if all the predicates defined for that rule are satisfied by the current thread&apos;s attributes (i&period;e&period;, `Rule&colon;&colon;evaluate()` returns `true` for the collection of attributes maintained by the current thread&apos;s `AttributeContext` object)&period;
| xref:BloombergLP/ball/LoggerManager/lookupCategory-0e.adoc[`lookupCategory`] 
| `lookupCategory` overloads
| xref:BloombergLP/ball/LoggerManager/maxNumCategories.adoc[`maxNumCategories`] 
| Return the current capacity of the category registry of this logger manager&period; A capacity of 0 implies that no limit will be imposed&semi; otherwise, new categories may be added only if `numCategories() &lt; maxNumCategories()`&period; Note that `0 &lt; maxNumCategories() &lt; numCategories()` _is_ a valid state, implying no new categories may be added&period;
| xref:BloombergLP/ball/LoggerManager/numCategories.adoc[`numCategories`] 
| Return the number of categories in the category registry of this logger manager&period;
| xref:BloombergLP/ball/LoggerManager/observer-09.adoc[`observer`] 
| `observer` overloads
| xref:BloombergLP/ball/LoggerManager/publishAll.adoc[`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&lowbar;PUBLISH&lowbar;ALL`&period;
| xref:BloombergLP/ball/LoggerManager/registerAttributeCollector.adoc[`registerAttributeCollector`] 
| Add the specified `collector` with the specified `collectorName` to the registry of attribute collectors maintained by this logger manager&period; Return 0 if `collector` was successfully registered with this logger manager, and a non&hyphen;zero value (with no effect) otherwise&period; Note that this method will fail if a collector having `collectorName` is already registered&period;
| xref:BloombergLP/ball/LoggerManager/registerObserver.adoc[`registerObserver`] 
| Add the specified `observer` with the specified `observerName` to the registry of observers maintained by this logger manager&period; Return 0 if `observer` was successfully registered with this logger manager, and a non&hyphen;zero value (with no effect) otherwise&period; Henceforth, all log records published by this logger manager are published to this observer, until `observer` is deregistered&period; The behavior is undefined if a cyclic reference is created among registered observers&period; Note that this method will fail if an observer having `observerName` is already registered&period;
| xref:BloombergLP/ball/LoggerManager/removeAllRules.adoc[`removeAllRules`] 
| Remove every rule from the set of rules maintained by this object&period;
| xref:BloombergLP/ball/LoggerManager/removeRule.adoc[`removeRule`] 
| Remove the rule having the specified `value` from this set of rules maintained by this object&period; Return the number of rules removed (i&period;e&period;, 1 on success and 0 if no rule having the same value is found&period;)
| xref:BloombergLP/ball/LoggerManager/removeRules.adoc[`removeRules`] 
| Remove each rule in the specified `ruleSet` from this set of rules maintained by this object&period; Return the number of rules removed&period;
| xref:BloombergLP/ball/LoggerManager/resetDefaultThresholdLevels.adoc[`resetDefaultThresholdLevels`] 
| Reset the default threshold levels of this logger manager to the original &quot;factory&hyphen;supplied&quot; default values or the factory overrides supplied at construction&period;
| xref:BloombergLP/ball/LoggerManager/ruleSet.adoc[`ruleSet`] 
| Return a `const` reference to the rule set maintained by this object&period;
| xref:BloombergLP/ball/LoggerManager/setCategory-07f.adoc[`setCategory`] 
| `setCategory` overloads
| xref:BloombergLP/ball/LoggerManager/setCategoryThresholdsToCurrentDefaults.adoc[`setCategoryThresholdsToCurrentDefaults`] 
| Set the threshold levels of the specified `category` in the category registry of this logger manager to the current default threshold values&period; The behavior is undefined unless `category` is non&hyphen;null&period;
| xref:BloombergLP/ball/LoggerManager/setCategoryThresholdsToFactoryDefaults.adoc[`setCategoryThresholdsToFactoryDefaults`] 
| Set the threshold levels of the specified `category` in the category registry of this logger manager to the original &quot;factory&hyphen;supplied&quot; default values or the factory overrides supplied at construction&period; The behavior is undefined unless `category` is non&hyphen;null&period;
| xref:BloombergLP/ball/LoggerManager/setDefaultThresholdLevels.adoc[`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 `&lsqb;0 &period;&period; 255&rsqb;`&period; Return 0 on success, and a non&hyphen;zero value otherwise (with no effect on any default threshold level)&period;
| xref:BloombergLP/ball/LoggerManager/setDefaultThresholdLevelsCallback.adoc[`setDefaultThresholdLevelsCallback`] 
| Set the default&hyphen;thresholds callback of this logger manager to the specified `callback`&period; The default&hyphen;thresholds callback is used to determine default threshold levels for categories added to the registry by the `setCategory(const char &ast;)` method&period;
| xref:BloombergLP/ball/LoggerManager/setLogger.adoc[`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&period; 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&period;
| xref:BloombergLP/ball/LoggerManager/setMaxNumCategories.adoc[`setMaxNumCategories`] 
| Set the capacity of the category registry of this logger manager to the specified `length`&period; If `length` is 0, no limit will be imposed&period; No categories are removed from the registry if the current number of categories exceeds `length`&period; However, subsequent attempts to add categories to the registry will fail&period; The behavior is undefined unless `0 &lt;&equals; length`&period;
| xref:BloombergLP/ball/LoggerManager/setThresholdLevelsHierarchically.adoc[`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`&period; In case `categoryNamePrefix` is empty set the threshold level of every existing category, and remove all preliminary settings (for future categories)&period; 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 `&lsqb;0 &period;&period; 255&rsqb;`&period; See also `ball&colon;&colon;CategoryManager&colon;&colon;setThresholdLevelsHierarchically`&period;
| xref:BloombergLP/ball/LoggerManager/thresholdLevelsForNewCategory.adoc[`thresholdLevelsForNewCategory`] 
| Load into the specified `&ast;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&period; Return 0 on success and a non&hyphen;zero value otherwise&period; If the client has configured a default threshold levels callback (see `ball&colon;&colon;LoggerManager&colon;&colon;DefaultThresholdLevelsCallback` in the component doc), the `categoryName` will be supplied to that callback which will set `&ast;levels`&period; Otherwise, if no default threshold levels callback has been provided, the default threshold levels are used&period; Note that this function will report an error if the callback returns invalid levels&period; 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&period;
| xref:BloombergLP/ball/LoggerManager/userFieldsPopulatorCallback-0c.adoc[`userFieldsPopulatorCallback`] 
| Return the address of the non&hyphen;modifiable user populator functor registered with this logger manager, or 0 if there is no registered user populator functor&period;
| xref:BloombergLP/ball/LoggerManager/visitCategories-0d.adoc[`visitCategories`] 
| `visitCategories` overloads
| xref:BloombergLP/ball/LoggerManager/visitObservers-06.adoc[`visitObservers`] 
| `visitObservers` overloads
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/LoggerManager/createLoggerManager-05.adoc[`createLoggerManager`] 
| `createLoggerManager` overloads
| xref:BloombergLP/ball/LoggerManager/getRecord.adoc[`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&period; Note that the returned `Record` must subsequently be supplied to a call to the `LoggerManager&colon;&colon;logMessage` method&period;
| xref:BloombergLP/ball/LoggerManager/initSingleton-01.adoc[`initSingleton`] 
| `initSingleton` overloads
| xref:BloombergLP/ball/LoggerManager/isInitialized.adoc[`isInitialized`] 
| Return `true` if the logger manager singleton exists, and `false` otherwise&period;
| xref:BloombergLP/ball/LoggerManager/logMessage.adoc[`logMessage`] 
| Publish the specified `record` using `bsls&colon;&colon;Log&colon;&colon;platformDefaultMessageHandler` after setting its severity attribute to the specified `severity`, and dispose of `record`&period; The behavior is undefined unless `record` was obtained by a call to the `LoggerManager&colon;&colon;getRecord` method&period; Note that `record` will be invalid after this method returns&period;
| xref:BloombergLP/ball/LoggerManager/obtainMessageBuffer-01.adoc[`obtainMessageBuffer`] 
| `obtainMessageBuffer` overloads
| xref:BloombergLP/ball/LoggerManager/shutDownSingleton.adoc[`shutDownSingleton`] 
| Destroy the logger manager singleton and release all resources used by it&period; This method has no effect if the logger manager singleton does not exist (i&period;e&period;, it has not been initialized or has already been destroyed)&period; The behavior is undefined if this method is called from one thread while another thread is accessing the logger manager singleton (i&period;e&period;, this method is _not_ thread&hyphen;safe)&period;
| xref:BloombergLP/ball/LoggerManager/singleton.adoc[`singleton`] 
| Return a non&hyphen;`const` reference to the logger manager singleton&period; The behavior is undefined unless the logger manager singleton exists&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/ball/LoggerManagerCategoryManip.adoc[BloombergLP::ball::LoggerManagerCategoryManip]`
| This class defines an iterator providing sequential, modifiable access to the categories in the registry of a logger manager&apos;s category manager&period; The order of the iteration is undefined&period;
| `xref:BloombergLP/ball/LoggerManagerCategoryIter.adoc[BloombergLP::ball::LoggerManagerCategoryIter]`
| This class defines an iterator providing sequential, read&hyphen;only access to the categories in the registry of a logger manager&apos;s category manager&period; The order of the iteration is undefined&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
