Observer that publishes log records to stdout and optionally a file.

Synopsis

Declared in <ball_fileobserver.h>

class FileObserver
    : public Observer

Description

This class implements the Observer protocol. The publish method of this class outputs the log records that it receives to stdout and optionally 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

OnFileRotationCallback

Alias for a user‐supplied callback invoked after log file rotation.

Member Functions

Name

Description

FileObserver [constructor]

Constructors

~FileObserver [destructor] [virtual]

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

allocator

Return the memory allocator used by this object.

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.

disableStdoutLoggingPrefix

Disable the long output format when logging to stdout.

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.

disableUserFieldsLogging [deprecated]

Disable the logging of user‐defined fields by this file observer.

enableFileLogging

enableFileLogging overloads

enablePublishInLocalTime

Enable publishing of record timestamps in local time.

enableStdoutLoggingPrefix

Enable the long output format when logging to stdout.

enableUserFieldsLogging [deprecated]

Enable the logging of user‐defined fields by this file observer.

forceRotation

Force an immediate log file rotation by this observer.

getFileLogFormat

Return the format specification used for log‐file records.

getLogFormat

Load the log‐file and stdout format specifications.

getStdoutLogFormat

Return the format specification used for stdout log records.

isFileLoggingEnabled

isFileLoggingEnabled overloads

isPublishInLocalTimeEnabled

Return true if published timestamps are written in local time.

isStdoutLoggingPrefixEnabled

Return true if the long stdout output format is in use.

isSuppressUniqueFileNameOnRotation

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

isUserFieldsLoggingEnabled [deprecated]

Return true if the logging of user‐defined fields is enabled for this file observer, 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 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.

setFileLogFormat

Set the format specification for log records written to the log file.

setLogFormat

Same as setLogFormats.

setLogFormats

Set the format specifications for log‐file and stdout records.

setOnFileRotationCallback

Set the callback invoked after each log file rotation attempt.

setStdoutLogFormat

Set the format specification for log records written to stdout.

setStdoutThreshold

Set the minimum severity of records logged to stdout.

stdoutThreshold

Return the minimum severity of records logged to stdout.

suppressUniqueFileNameOnRotation

Suppress or enable unique filenames when rotating the log file.

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

Declare that this type uses a bslma allocator.

Created with MrDocs