#include <ball_loggermanager.h>
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
◆ 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.
◆ 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]
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 |
◆ LoggerManager
The documentation for this class was generated from the following file: