[#BloombergLP-ball-FileObserver] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::FileObserver :relfileprefix: ../../ :mrdocs: Observer that publishes log records to `stdout` and optionally a file. == Synopsis Declared in `<ball_fileobserver.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class FileObserver : public xref:BloombergLP/ball/Observer.adoc[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 [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/ball/Observer.adoc[Observer]` | This class provides a protocol for receiving and processing log record output. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/FileObserver/OnFileRotationCallback.adoc[`OnFileRotationCallback`] | Alias for a user‐supplied callback invoked after log file rotation. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/FileObserver/2constructor-0f.adoc[`FileObserver`] [.small]#[constructor]# | Constructors | xref:BloombergLP/ball/FileObserver/2destructor.adoc[`~FileObserver`] [.small]#[destructor]# [.small]#[virtual]# | Close the log file of this file observer if file logging is enabled, and destroy this file observer. | xref:BloombergLP/ball/FileObserver/allocator.adoc[`allocator`] | Return the memory allocator used by this object. | xref:BloombergLP/ball/FileObserver/disableFileLogging.adoc[`disableFileLogging`] | Disable file logging for this file observer. | xref:BloombergLP/ball/FileObserver/disableLifetimeRotation.adoc[`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. | xref:BloombergLP/ball/FileObserver/disablePublishInLocalTime.adoc[`disablePublishInLocalTime`] | Disable publishing of record timestamps in local time. | xref:BloombergLP/ball/FileObserver/disableSizeRotation.adoc[`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. | xref:BloombergLP/ball/FileObserver/disableStdoutLoggingPrefix.adoc[`disableStdoutLoggingPrefix`] | Disable the long output format when logging to `stdout`. | xref:BloombergLP/ball/FileObserver/disableTimeIntervalRotation.adoc[`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. | xref:BloombergLP/ball/FileObserver/disableUserFieldsLogging.adoc[`disableUserFieldsLogging`] [.small]#[deprecated]# | Disable the logging of user‐defined fields by this file observer. | xref:BloombergLP/ball/FileObserver/enableFileLogging-06.adoc[`enableFileLogging`] | `enableFileLogging` overloads | xref:BloombergLP/ball/FileObserver/enablePublishInLocalTime.adoc[`enablePublishInLocalTime`] | Enable publishing of record timestamps in local time. | xref:BloombergLP/ball/FileObserver/enableStdoutLoggingPrefix.adoc[`enableStdoutLoggingPrefix`] | Enable the long output format when logging to `stdout`. | xref:BloombergLP/ball/FileObserver/enableUserFieldsLogging.adoc[`enableUserFieldsLogging`] [.small]#[deprecated]# | Enable the logging of user‐defined fields by this file observer. | xref:BloombergLP/ball/FileObserver/forceRotation.adoc[`forceRotation`] | Force an immediate log file rotation by this observer. | xref:BloombergLP/ball/FileObserver/getFileLogFormat.adoc[`getFileLogFormat`] | Return the format specification used for log‐file records. | xref:BloombergLP/ball/FileObserver/getLogFormat.adoc[`getLogFormat`] | Load the log‐file and `stdout` format specifications. | xref:BloombergLP/ball/FileObserver/getStdoutLogFormat.adoc[`getStdoutLogFormat`] | Return the format specification used for `stdout` log records. | xref:BloombergLP/ball/FileObserver/isFileLoggingEnabled-0657.adoc[`isFileLoggingEnabled`] | `isFileLoggingEnabled` overloads | xref:BloombergLP/ball/FileObserver/isPublishInLocalTimeEnabled.adoc[`isPublishInLocalTimeEnabled`] | Return `true` if published timestamps are written in local time. | xref:BloombergLP/ball/FileObserver/isStdoutLoggingPrefixEnabled.adoc[`isStdoutLoggingPrefixEnabled`] | Return `true` if the long `stdout` output format is in use. | xref:BloombergLP/ball/FileObserver/isSuppressUniqueFileNameOnRotation.adoc[`isSuppressUniqueFileNameOnRotation`] | Return `true` if the log filename uniqueness check on rotation is suppressed, and false otherwise. | xref:BloombergLP/ball/FileObserver/isUserFieldsLoggingEnabled.adoc[`isUserFieldsLoggingEnabled`] [.small]#[deprecated]# | Return `true` if the logging of user‐defined fields is enabled for this file observer, and `false` otherwise. | xref:BloombergLP/ball/FileObserver/localTimeOffset.adoc[`localTimeOffset`] | Return the local‐minus‐UTC offset captured at construction. | xref:BloombergLP/ball/FileObserver/publish-0d.adoc[`publish`] | Publish the specified log `record` with the given `context`. | xref:BloombergLP/ball/FileObserver/releaseRecords.adoc[`releaseRecords`] [.small]#[virtual]# | Discard shared references to `Record` objects held by this observer. | xref:BloombergLP/ball/FileObserver/rotateOnLifetime.adoc[`rotateOnLifetime`] | Configure periodic log file rotation at the specified `timeInterval`. | xref:BloombergLP/ball/FileObserver/rotateOnSize.adoc[`rotateOnSize`] | Rotate the log file when its size exceeds the specified `size`. | xref:BloombergLP/ball/FileObserver/rotateOnTimeInterval-02.adoc[`rotateOnTimeInterval`] | `rotateOnTimeInterval` overloads | xref:BloombergLP/ball/FileObserver/rotationLifetime.adoc[`rotationLifetime`] | Return the log file lifetime that triggers rotation, or zero. | xref:BloombergLP/ball/FileObserver/rotationSize.adoc[`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. | xref:BloombergLP/ball/FileObserver/setFileLogFormat.adoc[`setFileLogFormat`] | Set the format specification for log records written to the log file. | xref:BloombergLP/ball/FileObserver/setLogFormat.adoc[`setLogFormat`] | Same as `setLogFormats`. | xref:BloombergLP/ball/FileObserver/setLogFormats.adoc[`setLogFormats`] | Set the format specifications for log‐file and `stdout` records. | xref:BloombergLP/ball/FileObserver/setOnFileRotationCallback.adoc[`setOnFileRotationCallback`] | Set the callback invoked after each log file rotation attempt. | xref:BloombergLP/ball/FileObserver/setStdoutLogFormat.adoc[`setStdoutLogFormat`] | Set the format specification for log records written to `stdout`. | xref:BloombergLP/ball/FileObserver/setStdoutThreshold.adoc[`setStdoutThreshold`] | Set the minimum severity of records logged to `stdout`. | xref:BloombergLP/ball/FileObserver/stdoutThreshold.adoc[`stdoutThreshold`] | Return the minimum severity of records logged to `stdout`. | xref:BloombergLP/ball/FileObserver/suppressUniqueFileNameOnRotation.adoc[`suppressUniqueFileNameOnRotation`] | Suppress or enable unique filenames when rotating the log file. | xref:BloombergLP/ball/FileObserver/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<FileObserver, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#