Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Friends

ball::Logger Class Reference

#include <ball_loggermanager.h>

List of all members.

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


Member Typedef Documentation

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.


Member Function Documentation

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.

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

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.

char* ball::Logger::messageBuffer (  ) 

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.

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.

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.

void ball::Logger::publish (  ) 

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.

void ball::Logger::removeAll (  ) 

Remove all log records from the record buffer of this logger.

int ball::Logger::messageBufferSize (  )  const

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

int ball::Logger::numRecordsInUse (  )  const

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


Friends And Related Function Documentation

friend class LoggerManager [friend]

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