Observer that publishes log records to a user‐specified file.

Synopsis

Declared in <ball_fileobserver2.h>

class FileObserver2
    : public Observer

Description

This class implements the Observer protocol. The publish method of this class outputs the log records that it receives to a user‐specified file. This class is thread‐safe; different threads can operate on an object concurrently. This class is exception‐neutral with no guarantee of rollback. In no event is memory leaked.

Base Classes

Name

Description

Observer

This class provides a protocol for receiving and processing log record output.

Type Aliases

Name

Description

LogRecordFunctor

LogRecordFunctor is an alias for the type of the functor used for formatting log records to a stream.

OnFileRotationCallback

Callback invoked after each attempt to rotate the log file.

RecordFormatter

RecordFormatter is an alias for the type of the functor used for formatting log records to a stream.

Member Functions

Name

Description

FileObserver2 [constructor]

Create a file observer with file logging initially disabled.

~FileObserver2 [destructor] [virtual]

Close the log file of this file observer if file logging is enabled, and destroy this file observer.

disableFileLogging

Disable file logging for this file observer.

disableLifetimeRotation

Disable log file rotation based on a periodic time interval for this file observer. This method has no effect if rotation‐on‐time‐interval is not enabled.

disablePublishInLocalTime

Disable publishing of record timestamps in local time.

disableSizeRotation

Disable log file rotation based on log file size for this file observer. This method has no effect if rotation‐on‐size is not enabled.

disableTimeIntervalRotation

Disable log file rotation based on a periodic time interval for this file observer. This method has no effect if rotation‐on‐time‐interval is not enabled.

enableFileLogging

enableFileLogging overloads

enablePublishInLocalTime

Enable publishing of record timestamps in local time.

forceRotation

Force an immediate log file rotation by this observer.

getFormat

Return the format config of the last successful setFormat call.

isFileLoggingEnabled

isFileLoggingEnabled overloads

isPublishInLocalTimeEnabled

Return true if published timestamps are written in local time.

isSuppressUniqueFileNameOnRotation

Return true if the log filename uniqueness check on rotation is suppressed, and false otherwise.

localTimeOffset

Return the local‐minus‐UTC offset captured at construction.

publish

Publish the specified log record with the given context.

releaseRecords [virtual]

Discard shared references to published Record objects held by this observer.

rotateOnLifetime

Configure periodic log file rotation at the specified timeInterval.

rotateOnSize

Rotate the log file when its size exceeds the specified size.

rotateOnTimeInterval

rotateOnTimeInterval overloads

rotationLifetime

Return the log file lifetime that triggers rotation, or zero.

rotationSize

Return the size (in kilobytes) of the log file that will trigger a file rotation by this file observer if rotation‐on‐size is in effect, and 0 otherwise.

setFormat

Set the log‐file record format from the specified format string.

setLogFileFunctor

Set the formatting functor used when writing records to the log file.

setOnFileRotationCallback

Set the callback invoked after each log file rotation attempt.

suppressUniqueFileNameOnRotation

Suppress or enable unique filenames when rotating the log file.

operator BloombergLP::bslmf::NestedTraitDeclaration<FileObserver2, UsesBslmaAllocator>

Declare that this type uses a bslma allocator.

Created with MrDocs