[#BloombergLP-ball-FileObserver2] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::FileObserver2 :relfileprefix: ../../ :mrdocs: Observer that publishes log records to a user‐specified file. == Synopsis Declared in `<ball_fileobserver2.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class FileObserver2 : 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 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/FileObserver2/LogRecordFunctor.adoc[`LogRecordFunctor`] | `LogRecordFunctor` is an alias for the type of the functor used for formatting log records to a stream. | xref:BloombergLP/ball/FileObserver2/OnFileRotationCallback.adoc[`OnFileRotationCallback`] | Callback invoked after each attempt to rotate the log file. | xref:BloombergLP/ball/FileObserver2/RecordFormatter.adoc[`RecordFormatter`] | `RecordFormatter` is an alias for the type of the functor used for formatting log records to a stream. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/FileObserver2/2constructor.adoc[`FileObserver2`] [.small]#[constructor]# | Create a file observer with file logging initially disabled. | xref:BloombergLP/ball/FileObserver2/2destructor.adoc[`~FileObserver2`] [.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/FileObserver2/disableFileLogging.adoc[`disableFileLogging`] | Disable file logging for this file observer. | xref:BloombergLP/ball/FileObserver2/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/FileObserver2/disablePublishInLocalTime.adoc[`disablePublishInLocalTime`] | Disable publishing of record timestamps in local time. | xref:BloombergLP/ball/FileObserver2/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/FileObserver2/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/FileObserver2/enableFileLogging-0b.adoc[`enableFileLogging`] | `enableFileLogging` overloads | xref:BloombergLP/ball/FileObserver2/enablePublishInLocalTime.adoc[`enablePublishInLocalTime`] | Enable publishing of record timestamps in local time. | xref:BloombergLP/ball/FileObserver2/forceRotation.adoc[`forceRotation`] | Force an immediate log file rotation by this observer. | xref:BloombergLP/ball/FileObserver2/getFormat.adoc[`getFormat`] | Return the format config of the last successful `setFormat` call. | xref:BloombergLP/ball/FileObserver2/isFileLoggingEnabled-00.adoc[`isFileLoggingEnabled`] | `isFileLoggingEnabled` overloads | xref:BloombergLP/ball/FileObserver2/isPublishInLocalTimeEnabled.adoc[`isPublishInLocalTimeEnabled`] | Return `true` if published timestamps are written in local time. | xref:BloombergLP/ball/FileObserver2/isSuppressUniqueFileNameOnRotation.adoc[`isSuppressUniqueFileNameOnRotation`] | Return `true` if the log filename uniqueness check on rotation is suppressed, and false otherwise. | xref:BloombergLP/ball/FileObserver2/localTimeOffset.adoc[`localTimeOffset`] | Return the local‐minus‐UTC offset captured at construction. | xref:BloombergLP/ball/FileObserver2/publish-09.adoc[`publish`] | Publish the specified log `record` with the given `context`. | xref:BloombergLP/ball/FileObserver2/releaseRecords.adoc[`releaseRecords`] [.small]#[virtual]# | Discard shared references to published `Record` objects held by this observer. | xref:BloombergLP/ball/FileObserver2/rotateOnLifetime.adoc[`rotateOnLifetime`] | Configure periodic log file rotation at the specified `timeInterval`. | xref:BloombergLP/ball/FileObserver2/rotateOnSize.adoc[`rotateOnSize`] | Rotate the log file when its size exceeds the specified `size`. | xref:BloombergLP/ball/FileObserver2/rotateOnTimeInterval-0b.adoc[`rotateOnTimeInterval`] | `rotateOnTimeInterval` overloads | xref:BloombergLP/ball/FileObserver2/rotationLifetime.adoc[`rotationLifetime`] | Return the log file lifetime that triggers rotation, or zero. | xref:BloombergLP/ball/FileObserver2/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/FileObserver2/setFormat.adoc[`setFormat`] | Set the log‐file record format from the specified `format` string. | xref:BloombergLP/ball/FileObserver2/setLogFileFunctor.adoc[`setLogFileFunctor`] | Set the formatting functor used when writing records to the log file. | xref:BloombergLP/ball/FileObserver2/setOnFileRotationCallback.adoc[`setOnFileRotationCallback`] | Set the callback invoked after each log file rotation attempt. | xref:BloombergLP/ball/FileObserver2/suppressUniqueFileNameOnRotation.adoc[`suppressUniqueFileNameOnRotation`] | Suppress or enable unique filenames when rotating the log file. | xref:BloombergLP/ball/FileObserver2/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<FileObserver2, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#