[#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&period;

== Synopsis

Declared in `&lt;ball&lowbar;fileobserver&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class FileObserver
    : public xref:BloombergLP/ball/Observer.adoc[Observer]
----

== Description

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

== 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&period;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/FileObserver/OnFileRotationCallback.adoc[`OnFileRotationCallback`] 
| Alias for a user&hyphen;supplied callback invoked after log file rotation&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/FileObserver/2constructor-0f.adoc[`FileObserver`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/ball/FileObserver/2destructor.adoc[`&#126;FileObserver`] [.small]#[destructor]# [.small]#[virtual]#
| Close the log file of this file observer if file logging is enabled, and destroy this file observer&period;
| xref:BloombergLP/ball/FileObserver/allocator.adoc[`allocator`] 
| Return the memory allocator used by this object&period;
| xref:BloombergLP/ball/FileObserver/disableFileLogging.adoc[`disableFileLogging`] 
| Disable file logging for this file observer&period;
| xref:BloombergLP/ball/FileObserver/disableLifetimeRotation.adoc[`disableLifetimeRotation`] 
| Disable log file rotation based on a periodic time interval for this file observer&period; This method has no effect if rotation&hyphen;on&hyphen;time&hyphen;interval is not enabled&period;
| xref:BloombergLP/ball/FileObserver/disablePublishInLocalTime.adoc[`disablePublishInLocalTime`] 
| Disable publishing of record timestamps in local time&period;
| xref:BloombergLP/ball/FileObserver/disableSizeRotation.adoc[`disableSizeRotation`] 
| Disable log file rotation based on log file size for this file observer&period; This method has no effect if rotation&hyphen;on&hyphen;size is not enabled&period;
| xref:BloombergLP/ball/FileObserver/disableStdoutLoggingPrefix.adoc[`disableStdoutLoggingPrefix`] 
| Disable the long output format when logging to `stdout`&period;
| xref:BloombergLP/ball/FileObserver/disableTimeIntervalRotation.adoc[`disableTimeIntervalRotation`] 
| Disable log file rotation based on a periodic time interval for this file observer&period; This method has no effect if rotation&hyphen;on&hyphen;time&hyphen;interval is not enabled&period;
| xref:BloombergLP/ball/FileObserver/disableUserFieldsLogging.adoc[`disableUserFieldsLogging`]  [.small]#[deprecated]#
| Disable the logging of user&hyphen;defined fields by this file observer&period;
| 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&period;
| xref:BloombergLP/ball/FileObserver/enableStdoutLoggingPrefix.adoc[`enableStdoutLoggingPrefix`] 
| Enable the long output format when logging to `stdout`&period;
| xref:BloombergLP/ball/FileObserver/enableUserFieldsLogging.adoc[`enableUserFieldsLogging`]  [.small]#[deprecated]#
| Enable the logging of user&hyphen;defined fields by this file observer&period;
| xref:BloombergLP/ball/FileObserver/forceRotation.adoc[`forceRotation`] 
| Force an immediate log file rotation by this observer&period;
| xref:BloombergLP/ball/FileObserver/getFileLogFormat.adoc[`getFileLogFormat`] 
| Return the format specification used for log&hyphen;file records&period;
| xref:BloombergLP/ball/FileObserver/getLogFormat.adoc[`getLogFormat`] 
| Load the log&hyphen;file and `stdout` format specifications&period;
| xref:BloombergLP/ball/FileObserver/getStdoutLogFormat.adoc[`getStdoutLogFormat`] 
| Return the format specification used for `stdout` log records&period;
| 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&period;
| xref:BloombergLP/ball/FileObserver/isStdoutLoggingPrefixEnabled.adoc[`isStdoutLoggingPrefixEnabled`] 
| Return `true` if the long `stdout` output format is in use&period;
| xref:BloombergLP/ball/FileObserver/isSuppressUniqueFileNameOnRotation.adoc[`isSuppressUniqueFileNameOnRotation`] 
| Return `true` if the log filename uniqueness check on rotation is suppressed, and false otherwise&period;
| xref:BloombergLP/ball/FileObserver/isUserFieldsLoggingEnabled.adoc[`isUserFieldsLoggingEnabled`]  [.small]#[deprecated]#
| Return `true` if the logging of user&hyphen;defined fields is enabled for this file observer, and `false` otherwise&period;
| xref:BloombergLP/ball/FileObserver/localTimeOffset.adoc[`localTimeOffset`] 
| Return the local&hyphen;minus&hyphen;UTC offset captured at construction&period;
| xref:BloombergLP/ball/FileObserver/publish-0d.adoc[`publish`] 
| Publish the specified log `record` with the given `context`&period;
| xref:BloombergLP/ball/FileObserver/releaseRecords.adoc[`releaseRecords`]  [.small]#[virtual]#
| Discard shared references to `Record` objects held by this observer&period;
| xref:BloombergLP/ball/FileObserver/rotateOnLifetime.adoc[`rotateOnLifetime`] 
| Configure periodic log file rotation at the specified `timeInterval`&period;
| xref:BloombergLP/ball/FileObserver/rotateOnSize.adoc[`rotateOnSize`] 
| Rotate the log file when its size exceeds the specified `size`&period;
| 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&period;
| 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&hyphen;on&hyphen;size is in effect, and 0 otherwise&period;
| xref:BloombergLP/ball/FileObserver/setFileLogFormat.adoc[`setFileLogFormat`] 
| Set the format specification for log records written to the log file&period;
| xref:BloombergLP/ball/FileObserver/setLogFormat.adoc[`setLogFormat`] 
| Same as `setLogFormats`&period;
| xref:BloombergLP/ball/FileObserver/setLogFormats.adoc[`setLogFormats`] 
| Set the format specifications for log&hyphen;file and `stdout` records&period;
| xref:BloombergLP/ball/FileObserver/setOnFileRotationCallback.adoc[`setOnFileRotationCallback`] 
| Set the callback invoked after each log file rotation attempt&period;
| xref:BloombergLP/ball/FileObserver/setStdoutLogFormat.adoc[`setStdoutLogFormat`] 
| Set the format specification for log records written to `stdout`&period;
| xref:BloombergLP/ball/FileObserver/setStdoutThreshold.adoc[`setStdoutThreshold`] 
| Set the minimum severity of records logged to `stdout`&period;
| xref:BloombergLP/ball/FileObserver/stdoutThreshold.adoc[`stdoutThreshold`] 
| Return the minimum severity of records logged to `stdout`&period;
| xref:BloombergLP/ball/FileObserver/suppressUniqueFileNameOnRotation.adoc[`suppressUniqueFileNameOnRotation`] 
| Suppress or enable unique filenames when rotating the log file&period;
| xref:BloombergLP/ball/FileObserver/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;FileObserver, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
