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

#include <ball_loggermanager.h>

Public Types

typedef LoggerManagerConfiguration::UserFieldsPopulatorCallback UserFieldsPopulatorCallback
 
typedef bsl::function< void(Transmission::Cause)> PublishAllTriggerCallback
 

Public Member Functions

RecordgetRecord (const char *fileName, int lineNumber)
 
void logMessage (const Category &category, int severity, const char *fileName, int lineNumber, const char *message)
 
void logMessage (const Category &category, int severity, Record *record)
 
char * messageBuffer ()
 
char * obtainMessageBuffer (bslmt::Mutex **mutex, int *bufferSize)
 
bslma::ManagedPtr< char > obtainMessageBuffer (int *bufferSize)
 
void publish ()
 
void removeAll ()
 Remove all log records from the record buffer of this logger.
 
int messageBufferSize () const
 
int numRecordsInUse () const
 

Friends

class LoggerManager
 

Detailed Description

This class provides log record management services. Each instance of Logger receives log records from one or more clients, manages the storage of those records, and transmits them to a registered recipient (i.e., an observer) when appropriate.

See ball_loggermanager

Member Typedef Documentation

◆ PublishAllTriggerCallback

PublishAllTriggerCallback is the type of the functor that is invoked with the publication cause to publish all record buffers of all loggers that are allocated by the logger manager.

◆ UserFieldsPopulatorCallback

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

Member Function Documentation

◆ getRecord()

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

Return the address of a modifiable record having the specified fileName and lineNumber attributes, and retrieved from the object pool managed by this logger. Note that the returned Record must subsequently be supplied to a call to the 3-argument logMessage method on this logger.

◆ logMessage() [1/2]

void ball::Logger::logMessage ( const Category category,
int  severity,
const char *  fileName,
int  lineNumber,
const char *  message 
)

Log a record containing the specified message text, fileName, lineNumber, severity, and the name of the specified category. (See the component-level documentation of ball_record for more information on the additional fields that are logged.) Store the record in the buffer held by this logger if severity is at least as severe as the current "Record" threshold level of category. Pass the record directly to the observer held by this logger if severity is at least as severe as the current "Pass" threshold level of category. Publish the entire contents of the buffer of this logger if severity is at least as severe as the current "Trigger" threshold level of category. Publish the entire contents of all buffers of all active loggers of this logger factory if severity is at least as severe as the current "Trigger-All" threshold level of category (i.e., via the callback supplied at construction). Note that this method will have no effect if severity is less severe than all of the threshold levels of category. The behavior is undefined unless severity is in the range [1 .. 255].

◆ logMessage() [2/2]

void ball::Logger::logMessage ( const Category category,
int  severity,
Record record 
)

Log the specified *record after setting its category attribute to the name of the specified category and severity attribute to the specified severity. (See the component-level documentation of ball_record for more information on the fields that are logged.) Store the record in the buffer held by this logger if severity is at least as severe as the current "Record" threshold level of category. Pass the record directly to the observer held by this logger if severity is at least as severe as the current "Pass" threshold level of category. Publish the entire contents of the buffer of this logger if severity is at least as severe as the current "Trigger" threshold level of category. Publish the entire contents of all buffers of all active loggers if severity is at least as severe as the current "Trigger-All" threshold level of category (i.e., via the callback supplied at construction). Finally, dispose of record. This method has no effect (other than disposing of record) if severity is less severe than each of the threshold levels of category. The behavior is undefined unless severity is in the range [1 .. 255], both fileName and message are null-terminated, and record was previously obtained by a call to getRecord on this logger. Note that record will be invalid after this method returns.

◆ messageBuffer()

char * ball::Logger::messageBuffer ( )
inline

Return the address of the modifiable message buffer managed by this logger. Note that the returned buffer is intended to be used only for formatting log messages immediately before calling logMessage.

Deprecated:
Use obtainMessageBuffer instead. Do not use this method in multi-threaded code.

◆ messageBufferSize()

int ball::Logger::messageBufferSize ( ) const
inline

Return the size, in bytes, of the message buffer managed by this logger.

◆ numRecordsInUse()

int ball::Logger::numRecordsInUse ( ) const
inline

Return a snapshot of number of records that have been dispensed by getRecord but have not yet been supplied (returned) using logRecord.

◆ obtainMessageBuffer() [1/2]

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

Block until access to the buffer of this logger 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, until 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]

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

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.

◆ publish()

void ball::Logger::publish ( )
inline

Publish to the observer held by this logger all records stored in the record buffer of this logger and indicate to the observer that the cause is MANUAL_PUBLISH.

◆ removeAll()

void ball::Logger::removeAll ( )
inline

Friends And Related Symbol Documentation

◆ LoggerManager

friend class LoggerManager
friend

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