BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::LoggerManager Class Reference

#include <ball_loggermanager.h>

Public Types

typedef LoggerManagerConfiguration::CategoryNameFilterCallback CategoryNameFilterCallback
 
typedef LoggerManagerConfiguration::DefaultThresholdLevelsCallback DefaultThresholdLevelsCallback
 
typedef Logger::PublishAllTriggerCallback PublishAllTriggerCallback
 
typedef LoggerManagerConfiguration::UserFieldsPopulatorCallback UserFieldsPopulatorCallback
 
typedef AttributeCollectorRegistry::Collector AttributeCollector
 
typedef AttributeCollectorRegistry::Visitor AttributeVisitor
 
typedef BroadcastObserver::ObserverRegistry ObserverRegistry
 

Public Member Functions

 LoggerManager (const LoggerManagerConfiguration &configuration, bslma::Allocator *globalAllocator=0)
 
 ~LoggerManager ()
 Destroy this logger manager.
 
LoggerallocateLogger (RecordBuffer *buffer)
 
LoggerallocateLogger (RecordBuffer *buffer, int scratchBufferSize)
 
LoggerallocateLogger (RecordBuffer *buffer, Observer *observer)
 
LoggerallocateLogger (RecordBuffer *buffer, int scratchBufferSize, Observer *observer)
 
LoggerallocateLogger (RecordBuffer *buffer, const bsl::shared_ptr< Observer > &observer)
 
LoggerallocateLogger (RecordBuffer *buffer, int scratchBufferSize, const bsl::shared_ptr< Observer > &observer)
 
void deallocateLogger (Logger *logger)
 
LoggergetLogger ()
 
void setLogger (Logger *logger)
 
CategoryaddCategory (const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
 
CategorydefaultCategory ()
 
CategorylookupCategory (const char *categoryName)
 
const CategorysetCategory (const char *categoryName)
 
const CategorysetCategory (CategoryHolder *categoryHolder, const char *categoryName)
 
CategorysetCategory (const char *categoryName, int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
 
void setMaxNumCategories (int length)
 
void deregisterAllObservers ()
 
int deregisterObserver (const bsl::string_view &observerName)
 
int deregisterAttributeCollector (const bsl::string_view &collectorName)
 
bsl::shared_ptr< ObserverfindObserver (const bsl::string_view &observerName)
 
template<class t_OBSERVER >
int findObserver (bsl::shared_ptr< t_OBSERVER > *result, const bsl::string_view &observerName)
 
Observerobserver ()
 
int registerObserver (const bsl::shared_ptr< Observer > &observer, const bsl::string_view &observerName)
 
int registerAttributeCollector (const AttributeCollector &collector, const bsl::string_view &collectorName)
 
void resetDefaultThresholdLevels ()
 
void setCategoryThresholdsToCurrentDefaults (Category *category)
 
void setCategoryThresholdsToFactoryDefaults (Category *category)
 
int setDefaultThresholdLevels (int recordLevel, int passLevel, int triggerLevel, int triggerAllLevel)
 
void setDefaultThresholdLevelsCallback (DefaultThresholdLevelsCallback *callback)
 
int addRule (const Rule &value)
 
int addRules (const RuleSet &ruleSet)
 
void removeAllRules ()
 Remove every rule from the set of rules maintained by this object.
 
int removeRule (const Rule &value)
 
int removeRules (const RuleSet &ruleSet)
 
void publishAll ()
 
template<class t_CATEGORY_VISITOR >
void visitCategories (const t_CATEGORY_VISITOR &visitor)
 
template<class t_OBSERVER_VISITOR >
void visitObservers (BSLS_COMPILERFEATURES_FORWARD_REF(t_OBSERVER_VISITOR) visitor)
 
bslma::Allocatorallocator () const
 
const CategorydefaultCategory () const
 
int defaultPassThresholdLevel () const
 Return the default pass threshold level of this logger manager.
 
int defaultRecordThresholdLevel () const
 Return the default record threshold level of this logger manager.
 
int defaultTriggerAllThresholdLevel () const
 
int defaultTriggerThresholdLevel () const
 Return the default trigger threshold level of this logger manager.
 
bsl::shared_ptr< const ObserverfindObserver (const bsl::string_view &observerName) const
 
template<class t_OBSERVER >
int findObserver (bsl::shared_ptr< const t_OBSERVER > *result, const bsl::string_view &observerName) const
 
bool isCategoryEnabled (const Category *category, int severity) const
 
const CategorylookupCategory (const char *categoryName) const
 
int maxNumCategories () const
 
int numCategories () const
 
const Observerobserver () const
 
const RuleSetruleSet () const
 
const UserFieldsPopulatorCallbackuserFieldsPopulatorCallback () const
 
template<class t_CATEGORY_VISITOR >
void visitCategories (const t_CATEGORY_VISITOR &visitor) const
 
template<class t_OBSERVER_VISITOR >
void visitObservers (BSLS_COMPILERFEATURES_FORWARD_REF(t_OBSERVER_VISITOR) visitor) const
 
const ThresholdAggregatedefaultThresholdLevels () const
 
int thresholdLevelsForNewCategory (ThresholdAggregate *levels, const char *categoryName) const
 

Static Public Member Functions

static void createLoggerManager (bslma::ManagedPtr< LoggerManager > *manager, Observer *observer, const LoggerManagerConfiguration &configuration, bslma::Allocator *basicAllocator=0)
 
static void createLoggerManager (bslma::ManagedPtr< LoggerManager > *manager, const LoggerManagerConfiguration &configuration, bslma::Allocator *basicAllocator=0)
 
static RecordgetRecord (const char *fileName, int lineNumber)
 
static LoggerManagerinitSingleton (Observer *observer, bslma::Allocator *globalAllocator=0)
 
static LoggerManagerinitSingleton (Observer *observer, const LoggerManagerConfiguration &configuration, bslma::Allocator *globalAllocator=0)
 
static LoggerManagerinitSingleton (bslma::Allocator *globalAllocator=0)
 
static LoggerManagerinitSingleton (const LoggerManagerConfiguration &configuration, bslma::Allocator *globalAllocator=0)
 
static int initSingleton (LoggerManager *singleton, bool adoptSingleton=false)
 
static bool isInitialized ()
 
static void logMessage (int severity, Record *record)
 
static char * obtainMessageBuffer (bslmt::Mutex **mutex, int *bufferSize)
 
static bslma::ManagedPtr< char > obtainMessageBuffer (int *bufferSize)
 
static void shutDownSingleton ()
 
static LoggerManagersingleton ()
 

Friends

class LoggerManagerCategoryIter
 
class LoggerManagerCategoryManip
 

Detailed Description

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.

See ball_loggermanager

Member Typedef Documentation

◆ 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.

Constructor & Destructor Documentation

◆ LoggerManager()

ball::LoggerManager::LoggerManager ( const LoggerManagerConfiguration configuration,
bslma::Allocator globalAllocator = 0 
)
explicit

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()

ball::LoggerManager::~LoggerManager ( )

Member Function Documentation

◆ addCategory()

Category * ball::LoggerManager::addCategory ( const char *  categoryName,
int  recordLevel,
int  passLevel,
int  triggerLevel,
int  triggerAllLevel 
)

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.

◆ addRule()

int ball::LoggerManager::addRule ( const Rule value)
inline

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()

int ball::LoggerManager::addRules ( const RuleSet ruleSet)
inline

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() [1/6]

Logger * ball::LoggerManager::allocateLogger ( RecordBuffer buffer)

Return the address of a modifiable logger managed by this logger manager configured with the specified record buffer. Optionally specify a scratchBufferSize for the logger's user-accessible message buffer. If scratchBufferSize is not specified, the value configured at construction is used. Note that this method is primarily intended for use in multi-threaded applications, but can be used to partition logging streams even within a single thread. Also note that ownership of buffer is not transferred, and hence, will not be destroyed (or otherwise affected) after the logger is deallocated.

◆ allocateLogger() [2/6]

Logger * ball::LoggerManager::allocateLogger ( RecordBuffer buffer,
const bsl::shared_ptr< Observer > &  observer 
)

Return the address of a modifiable logger managed by this logger manager having the specified observer that receives published log records and configured with the specified record buffer. Optionally specify a scratchBufferSize for the logger's user-accessible message buffer. If scratchBufferSize is not specified, the value configured at construction is used. Note that this method is primarily intended for use in multi-threaded applications, but can be used to partition logging streams even within a single thread. Also note that ownership of buffer and observer is not transferred, and hence, will not be destroyed (or otherwise affected) after the logger is deallocated.

◆ allocateLogger() [3/6]

Logger * ball::LoggerManager::allocateLogger ( RecordBuffer buffer,
int  scratchBufferSize 
)

◆ allocateLogger() [4/6]

Logger * ball::LoggerManager::allocateLogger ( RecordBuffer buffer,
int  scratchBufferSize,
const bsl::shared_ptr< Observer > &  observer 
)

◆ allocateLogger() [5/6]

Logger * ball::LoggerManager::allocateLogger ( RecordBuffer buffer,
int  scratchBufferSize,
Observer observer 
)

◆ allocateLogger() [6/6]

Logger * ball::LoggerManager::allocateLogger ( RecordBuffer buffer,
Observer observer 
)

Return the address of a modifiable logger managed by this logger manager having the specified observer that receives published log records and configured with the specified record buffer. Optionally specify a scratchBufferSize for the logger's user-accessible message buffer. If scratchBufferSize is not specified, the value configured at construction is used. Note that this method is primarily intended for use in multi-threaded applications, but can be used to partition logging streams even within a single thread. Also note that ownership of buffer and observer is not transferred, and hence, will not be destroyed (or otherwise affected) after the logger is deallocated.

Deprecated:
Use allocateLogger method that does not take a raw pointer to an observer, together with the registerObserver method (which takes a shared pointer to an observer), instead.

◆ allocator()

bslma::Allocator * ball::LoggerManager::allocator ( ) const
inline

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

◆ createLoggerManager() [1/2]

static void ball::LoggerManager::createLoggerManager ( bslma::ManagedPtr< LoggerManager > *  manager,
const LoggerManagerConfiguration configuration,
bslma::Allocator basicAllocator = 0 
)
static

Create a logger manager that is not the singleton logger manager having the specified configuration of defaults and attributes; load the newly-created logger manager into the specified manager managed pointer. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that this method does not create the singleton logger manager used by the macros of the BALL logging framework.

◆ createLoggerManager() [2/2]

static void ball::LoggerManager::createLoggerManager ( bslma::ManagedPtr< LoggerManager > *  manager,
Observer observer,
const LoggerManagerConfiguration configuration,
bslma::Allocator basicAllocator = 0 
)
static

Create a logger manager that is not the singleton logger manager having the specified observer that receives published log records and the specified configuration of defaults and attributes; load the newly-created logger manager into the specified manager managed pointer. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined if observer is 0, goes out of scope, or is otherwise destroyed. Note that this method does not create the singleton logger manager used by the macros of the BALL logging framework.

Deprecated:
Use createLoggerManager method that does not take a raw pointer to an observer, together with the registerObserver method (which takes a shared pointer to an observer), instead.

◆ deallocateLogger()

void ball::LoggerManager::deallocateLogger ( Logger logger)

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() [1/2]

Category & ball::LoggerManager::defaultCategory ( )
inline

Return a non-const reference to the Default Category in the category registry of this logger manager.

◆ defaultCategory() [2/2]

const Category & ball::LoggerManager::defaultCategory ( ) const
inline

Return a const reference to the Default Category in the category registry of this logger manager.

◆ defaultPassThresholdLevel()

int ball::LoggerManager::defaultPassThresholdLevel ( ) const
inline

◆ defaultRecordThresholdLevel()

int ball::LoggerManager::defaultRecordThresholdLevel ( ) const
inline

◆ defaultThresholdLevels()

const ThresholdAggregate & ball::LoggerManager::defaultThresholdLevels ( ) const

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

◆ defaultTriggerAllThresholdLevel()

int ball::LoggerManager::defaultTriggerAllThresholdLevel ( ) const
inline

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

◆ defaultTriggerThresholdLevel()

int ball::LoggerManager::defaultTriggerThresholdLevel ( ) const
inline

◆ deregisterAllObservers()

void ball::LoggerManager::deregisterAllObservers ( )
inline

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

◆ deregisterAttributeCollector()

int ball::LoggerManager::deregisterAttributeCollector ( const bsl::string_view collectorName)
inline

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()

int ball::LoggerManager::deregisterObserver ( const bsl::string_view observerName)
inline

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() [1/4]

template<class t_OBSERVER >
int ball::LoggerManager::findObserver ( bsl::shared_ptr< const t_OBSERVER > *  result,
const bsl::string_view observerName 
) const
inline

Load into the specified result a shared pointer to the observer of (template parameter) t_OBSERVER type having the specified observerName in the registry of this logger manager, and an empty shared pointer if there is no such observer otherwise. Return 0 if a non-empty shared pointer was loaded, and a non-zero value otherwise. Note that an empty shared pointer will be loaded if either no observer having observerName is in the registry or the observer registered with that name is not of t_OBSERVER type.

◆ findObserver() [2/4]

template<class t_OBSERVER >
int ball::LoggerManager::findObserver ( bsl::shared_ptr< t_OBSERVER > *  result,
const bsl::string_view observerName 
)
inline

Load into the specified result a shared pointer to the observer of (template parameter) t_OBSERVER type having the specified observerName in the registry of this logger manager, and an empty shared pointer if there is no such observer otherwise. Return 0 if a non-empty shared pointer was loaded, and a non-zero value otherwise. Note that an empty shared pointer will be loaded if either no observer having observerName is in the registry or the observer registered with that name is not of t_OBSERVER type.

◆ findObserver() [3/4]

bsl::shared_ptr< Observer > ball::LoggerManager::findObserver ( const bsl::string_view observerName)
inline

Return a shared pointer to the observer having the specified observerName in the registry of this logger manager, and an empty shared pointer if there is no such observer otherwise.

◆ findObserver() [4/4]

bsl::shared_ptr< const Observer > ball::LoggerManager::findObserver ( const bsl::string_view observerName) const
inline

Return a shared pointer to the observer having the specified observerName in the registry of this logger manager, and an empty shared pointer if there is no such observer otherwise.

◆ getLogger()

Logger & ball::LoggerManager::getLogger ( )

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

◆ getRecord()

static Record * ball::LoggerManager::getRecord ( const char *  fileName,
int  lineNumber 
)
static

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() [1/5]

static LoggerManager & ball::LoggerManager::initSingleton ( bslma::Allocator globalAllocator = 0)
static

Initialize the logger manager singleton. Optionally specify a configuration describing how the singleton should be configured. If configuration is not specified, a default constructed LoggerManagerConfiguration object is used. Optionally specify a globalAllocator used to supply memory. If globalAllocator is 0, the currently installed global allocator is used. Return a non-const reference to the logger manager singleton. This method has no effect (aside from logging a warning) if the logger manager singleton already exists.

◆ initSingleton() [2/5]

static LoggerManager & ball::LoggerManager::initSingleton ( const LoggerManagerConfiguration configuration,
bslma::Allocator globalAllocator = 0 
)
static

◆ initSingleton() [3/5]

static int ball::LoggerManager::initSingleton ( LoggerManager singleton,
bool  adoptSingleton = false 
)
static

Initialize the logger manager singleton with the specified singleton. Optionally specify an adoptSingleton flag indicating whether this method takes ownership of singleton, in which case shutDownSingleton will destroy singleton. If adoptSingleton is not specified, this method does not take ownership of singleton (and shutDownSingleton will not destroy it). Return 0 if the logger manager singleton was successfully initialized, and a non-zero value otherwise. This method has no effect (aside from logging a warning) if the logger manager singleton already exists, in which case this method does not take ownership of singleton regardless of the value of adoptSingleton. Note that this version of initSingleton is meant for use only on Windows to initialize another dynamically loaded copy of the LoggerManager system. Also note that a suitable singleton may be obtained by calling createLoggerManager, or from the singleton class method of an already-initialized LoggerManager system.

◆ initSingleton() [4/5]

static LoggerManager & ball::LoggerManager::initSingleton ( Observer observer,
bslma::Allocator globalAllocator = 0 
)
static

Initialize the logger manager singleton having the specified observer that receives published log records. Optionally specify a configuration describing how the singleton should be configured. If configuration is not specified, a default constructed LoggerManagerConfiguration object is used. Optionally specify a globalAllocator used to supply memory. If globalAllocator is 0, the currently installed global allocator is used. Return a non-const reference to the logger manager singleton. This method has no effect (aside from logging a warning) if the logger manager singleton already exists. The behavior is undefined if observer is 0, goes out of scope, or is otherwise destroyed.

Deprecated:
Use initSingleton method that does not take a raw pointer to an observer, together with the registerObserver method (which takes a shared pointer to an observer), instead.

◆ initSingleton() [5/5]

static LoggerManager & ball::LoggerManager::initSingleton ( Observer observer,
const LoggerManagerConfiguration configuration,
bslma::Allocator globalAllocator = 0 
)
static

◆ isCategoryEnabled()

bool ball::LoggerManager::isCategoryEnabled ( const Category category,
int  severity 
) const

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).

◆ isInitialized()

bool ball::LoggerManager::isInitialized ( )
inlinestatic

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

◆ logMessage()

static void ball::LoggerManager::logMessage ( int  severity,
Record record 
)
static

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.

◆ lookupCategory() [1/2]

Category * ball::LoggerManager::lookupCategory ( const char *  categoryName)

Return the address of the modifiable category in the category registry of this logger manager having the specified categoryName, or 0 if no such category exists. The behavior is undefined unless categoryName is null-terminated.

◆ lookupCategory() [2/2]

const Category * ball::LoggerManager::lookupCategory ( const char *  categoryName) const

Return the address of the non-modifiable category in the category registry of this logger manager having the specified categoryName, or 0 if no such category exists. The behavior is undefined unless categoryName is null-terminated.

◆ maxNumCategories()

int ball::LoggerManager::maxNumCategories ( ) const
inline

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()

int ball::LoggerManager::numCategories ( ) const
inline

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

◆ observer() [1/2]

Observer * ball::LoggerManager::observer ( )

Return the address of the modifiable legacy observer registered with this logger manager.

Deprecated:
Use findObserver instead.

◆ observer() [2/2]

const Observer * ball::LoggerManager::observer ( ) const

Return the address of the non-modifiable observer registered with this logger manager.

Deprecated:
Use findObserver instead.

◆ obtainMessageBuffer() [1/2]

static char * ball::LoggerManager::obtainMessageBuffer ( bslmt::Mutex **  mutex,
int *  bufferSize 
)
static

Block until access to the static buffer used for formatting messages is available. Return the address of the modifiable buffer to which this thread of execution has exclusive access, load the address of the mutex that protects the buffer into the specified *mutex address, and load the size (in bytes) of the buffer into the specified bufferSize address. The address remains valid, and the buffer remains locked by this thread of execution, this thread calls mutex->unlock(). The behavior is undefined if this thread of execution currently holds a lock on the buffer. Note that the buffer is intended to be used only for formatting log messages immediately before calling logMessage; other use may adversely affect performance for the entire program.

◆ obtainMessageBuffer() [2/2]

static bslma::ManagedPtr< char > ball::LoggerManager::obtainMessageBuffer ( int *  bufferSize)
static

Return a managed pointer that refers to the memory block to which this thread of execution has exclusive access and load the size (in bytes) of this buffer into the specified bufferSize address. Note that this method is intended for internal use only.

◆ publishAll()

void ball::LoggerManager::publishAll ( )
inline

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()

int ball::LoggerManager::registerAttributeCollector ( const AttributeCollector collector,
const bsl::string_view collectorName 
)
inline

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()

int ball::LoggerManager::registerObserver ( const bsl::shared_ptr< Observer > &  observer,
const bsl::string_view observerName 
)
inline

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()

void ball::LoggerManager::removeAllRules ( )
inline

◆ removeRule()

int ball::LoggerManager::removeRule ( const Rule value)
inline

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()

int ball::LoggerManager::removeRules ( const RuleSet ruleSet)
inline

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

◆ resetDefaultThresholdLevels()

void ball::LoggerManager::resetDefaultThresholdLevels ( )
inline

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

◆ ruleSet()

const RuleSet & ball::LoggerManager::ruleSet ( ) const
inline

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

◆ setCategory() [1/3]

const Category * ball::LoggerManager::setCategory ( CategoryHolder categoryHolder,
const char *  categoryName 
)

Add to the category registry of this logger manager a new category having the specified categoryName and default threshold levels if categoryName is not present in the registry and the number of categories in the registry is less than the registry capacity. Return the address of the (possibly newly-created) non-modifiable category having categoryName, if such a category exists, and the address of the non-modifiable Default Category otherwise. If the specified categoryHolder is non-null, then also load into categoryHolder the returned category and its maximum level and link categoryHolder to the category if it has not yet been linked. The behavior is undefined unless categoryName is null-terminated. Note that a valid category address is always returned.

◆ setCategory() [2/3]

const Category * ball::LoggerManager::setCategory ( const char *  categoryName)
inline

Add to the category registry of this logger manager a new category having the specified categoryName and default threshold levels if categoryName is not present in the registry and the number of categories in the registry is less than the registry capacity. Return the address of the (possibly newly-created) non-modifiable category having categoryName, if such a category exists, and the address of the non-modifiable Default Category otherwise. The behavior is undefined unless categoryName is null-terminated. Note that a valid category address is always returned.

◆ setCategory() [3/3]

Category * ball::LoggerManager::setCategory ( const char *  categoryName,
int  recordLevel,
int  passLevel,
int  triggerLevel,
int  triggerAllLevel 
)

Add to the category registry of this logger manager a new category having the specified categoryName and 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) recordLevel, passLevel, triggerLevel, and triggerAllLevel are all within the range [0 .. 255]. If categoryName is already present and each threshold level is within the valid range then reset the threshold levels of categoryName to the specified values. Return the address of the (possibly newly-created) modifiable category having categoryName if categoryName was either created or its thresholds reset, and 0 otherwise. The behavior is undefined unless categoryName is null-terminated. Note that 0, and not the Default Category, is returned on failure.

◆ setCategoryThresholdsToCurrentDefaults()

void ball::LoggerManager::setCategoryThresholdsToCurrentDefaults ( Category category)

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()

void ball::LoggerManager::setCategoryThresholdsToFactoryDefaults ( Category category)

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()

int ball::LoggerManager::setDefaultThresholdLevels ( int  recordLevel,
int  passLevel,
int  triggerLevel,
int  triggerAllLevel 
)

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()

void ball::LoggerManager::setDefaultThresholdLevelsCallback ( DefaultThresholdLevelsCallback callback)

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()

void ball::LoggerManager::setLogger ( Logger logger)

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()

void ball::LoggerManager::setMaxNumCategories ( int  length)

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.

◆ shutDownSingleton()

static void ball::LoggerManager::shutDownSingleton ( )
static

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()

LoggerManager & ball::LoggerManager::singleton ( )
inlinestatic

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

◆ thresholdLevelsForNewCategory()

int ball::LoggerManager::thresholdLevelsForNewCategory ( ThresholdAggregate levels,
const char *  categoryName 
) const

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()

const UserFieldsPopulatorCallback * ball::LoggerManager::userFieldsPopulatorCallback ( ) const

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() [1/2]

template<class t_CATEGORY_VISITOR >
void ball::LoggerManager::visitCategories ( const t_CATEGORY_VISITOR &  visitor)
inline

Invoke the specified visitor functor on each category managed by this object, providing that functor modifiable access to each category. visitor must be a functor that can be called as if it had the following signature:

void operator()(Category *);
Definition ball_category.h:184

◆ visitCategories() [2/2]

template<class t_CATEGORY_VISITOR >
void ball::LoggerManager::visitCategories ( const t_CATEGORY_VISITOR &  visitor) const
inline

Invoke the specified visitor functor on each category managed by this object, providing that functor non-modifiable access to each category. visitor must be a functor that can be called as if it had the following signature:

void operator()(const Category *);

◆ visitObservers() [1/2]

template<class t_OBSERVER_VISITOR >
void ball::LoggerManager::visitObservers ( BSLS_COMPILERFEATURES_FORWARD_REF(t_OBSERVER_VISITOR)  visitor)
inline

Invoke the specified visitor functor of (template parameter) t_OBSERVER_VISITOR type on each element in the registry of this logger manager, supplying that functor modifiable access to each observer. visitor must be a functor that can be called as if it had the following signature:

void operator()(const bsl::shared_ptr<Observer>& observer,
const bsl::string_view& observerName);
Observer * observer()
Definition bslstl_stringview.h:441
Definition bslstl_sharedptr.h:1830

◆ visitObservers() [2/2]

template<class t_OBSERVER_VISITOR >
void ball::LoggerManager::visitObservers ( BSLS_COMPILERFEATURES_FORWARD_REF(t_OBSERVER_VISITOR)  visitor) const
inline

Invoke the specified visitor functor of (template parameter) t_OBSERVER_VISITOR type on each element in the registry of this logger manager, supplying that functor modifiable access to each observer. visitor must be a functor that can be called as if it had the following signature:

void operator()(const bsl::shared_ptr<Observer>& observer,
const bsl::string_view& observerName);

Friends And Related Symbol Documentation

◆ LoggerManagerCategoryIter

friend class LoggerManagerCategoryIter
friend

◆ LoggerManagerCategoryManip

friend class LoggerManagerCategoryManip
friend

The documentation for this class was generated from the following file: