[#BloombergLP-ball-AsyncFileObserver]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::AsyncFileObserver
:relfileprefix: ../../
:mrdocs:

Asynchronous observer that publishes log records to `stdout` and a file&period;

== Synopsis

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

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

== Description

This class implements the `Observer` protocol&period; The `publish` method of this class outputs log records asynchronously 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/AsyncFileObserver/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/AsyncFileObserver/2constructor-0b.adoc[`AsyncFileObserver`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/ball/AsyncFileObserver/2destructor.adoc[`&#126;AsyncFileObserver`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this observer after draining and stopping publication&period;
| xref:BloombergLP/ball/AsyncFileObserver/disableFileLogging.adoc[`disableFileLogging`] 
| Disable file logging for this async file observer&period;
| xref:BloombergLP/ball/AsyncFileObserver/disablePublishInLocalTime.adoc[`disablePublishInLocalTime`] 
| Disable publishing of record timestamps in local time&period;
| xref:BloombergLP/ball/AsyncFileObserver/disableSizeRotation.adoc[`disableSizeRotation`] 
| Disable log file rotation based on log file size for this async file observer&period; This method has no effect if rotation&hyphen;on&hyphen;size is not enabled&period;
| xref:BloombergLP/ball/AsyncFileObserver/disableStdoutLoggingPrefix.adoc[`disableStdoutLoggingPrefix`] 
| Disable the long output format when logging to `stdout`&period;
| xref:BloombergLP/ball/AsyncFileObserver/disableTimeIntervalRotation.adoc[`disableTimeIntervalRotation`] 
| Disable log file rotation based on a periodic time interval for this async file observer&period; This method has no effect if rotation&hyphen;on&hyphen;time&hyphen;interval is not enabled&period;
| xref:BloombergLP/ball/AsyncFileObserver/enableFileLogging.adoc[`enableFileLogging`] 
| Enable file logging using a name derived from `logFilenamePattern`&period;
| xref:BloombergLP/ball/AsyncFileObserver/enablePublishInLocalTime.adoc[`enablePublishInLocalTime`] 
| Enable publishing of record timestamps in local time&period;
| xref:BloombergLP/ball/AsyncFileObserver/enableStdoutLoggingPrefix.adoc[`enableStdoutLoggingPrefix`] 
| Enable the long output format when logging to `stdout`&period;
| xref:BloombergLP/ball/AsyncFileObserver/forceRotation.adoc[`forceRotation`] 
| Force an immediate log file rotation by this observer&period;
| xref:BloombergLP/ball/AsyncFileObserver/getFileLogFormat.adoc[`getFileLogFormat`] 
| Return the format specification used for log&hyphen;file records&period;
| xref:BloombergLP/ball/AsyncFileObserver/getLogFormat.adoc[`getLogFormat`] 
| Load the log&hyphen;file and `stdout` format specifications&period;
| xref:BloombergLP/ball/AsyncFileObserver/getStdoutLogFormat.adoc[`getStdoutLogFormat`] 
| Return the format specification used for `stdout` log records&period;
| xref:BloombergLP/ball/AsyncFileObserver/isFileLoggingEnabled-0ac.adoc[`isFileLoggingEnabled`] 
| `isFileLoggingEnabled` overloads
| xref:BloombergLP/ball/AsyncFileObserver/isPublicationThreadRunning.adoc[`isPublicationThreadRunning`] 
| Return `true` if a publication thread is currently running&period;
| xref:BloombergLP/ball/AsyncFileObserver/isPublishInLocalTimeEnabled.adoc[`isPublishInLocalTimeEnabled`] 
| Return `true` if published timestamps are written in local time&period;
| xref:BloombergLP/ball/AsyncFileObserver/isStdoutLoggingPrefixEnabled.adoc[`isStdoutLoggingPrefixEnabled`] 
| Return `true` if the long `stdout` output format is in use&period;
| xref:BloombergLP/ball/AsyncFileObserver/isSuppressUniqueFileNameOnRotation.adoc[`isSuppressUniqueFileNameOnRotation`] 
| Return `true` if the log filename uniqueness check on rotation is suppressed, and false otherwise&period;
| xref:BloombergLP/ball/AsyncFileObserver/isUserFieldsLoggingEnabled.adoc[`isUserFieldsLoggingEnabled`]  [.small]#[deprecated]#
| Return `true` if the logging of user&hyphen;defined fields is enabled for this async file observer, and `false` otherwise&period;
| xref:BloombergLP/ball/AsyncFileObserver/localTimeOffset.adoc[`localTimeOffset`] 
| Return the local&hyphen;minus&hyphen;UTC offset captured at construction&period;
| xref:BloombergLP/ball/AsyncFileObserver/publish-00.adoc[`publish`] 
| `publish` overloads
| xref:BloombergLP/ball/AsyncFileObserver/recordQueueLength.adoc[`recordQueueLength`] 
| Return the number of log records currently on the record queue of this async file observer&period;
| xref:BloombergLP/ball/AsyncFileObserver/releaseRecords.adoc[`releaseRecords`]  [.small]#[virtual]#
| Discard shared references to `Record` objects held by this observer&period;
| xref:BloombergLP/ball/AsyncFileObserver/rotateOnSize.adoc[`rotateOnSize`] 
| Rotate the log file when its size exceeds the specified `size`&period;
| xref:BloombergLP/ball/AsyncFileObserver/rotateOnTimeInterval-07.adoc[`rotateOnTimeInterval`] 
| `rotateOnTimeInterval` overloads
| xref:BloombergLP/ball/AsyncFileObserver/rotationLifetime.adoc[`rotationLifetime`] 
| Return the log file lifetime that triggers rotation, or zero&period;
| xref:BloombergLP/ball/AsyncFileObserver/rotationSize.adoc[`rotationSize`] 
| Return the size (in kilobytes) of the log file that will trigger a file rotation by this async file observer if rotation&hyphen;on&hyphen;size is in effect, and 0 otherwise&period;
| xref:BloombergLP/ball/AsyncFileObserver/setFileLogFormat.adoc[`setFileLogFormat`] 
| Set the format specification for log records written to the log file&period;
| xref:BloombergLP/ball/AsyncFileObserver/setLogFormat.adoc[`setLogFormat`] 
| Same as `setLogFormats`&period;
| xref:BloombergLP/ball/AsyncFileObserver/setLogFormats.adoc[`setLogFormats`] 
| Set the format specifications for log&hyphen;file and `stdout` records&period;
| xref:BloombergLP/ball/AsyncFileObserver/setOnFileRotationCallback.adoc[`setOnFileRotationCallback`] 
| Set the callback invoked after each log file rotation attempt&period;
| xref:BloombergLP/ball/AsyncFileObserver/setStdoutLogFormat.adoc[`setStdoutLogFormat`] 
| Set the format specification for log records written to `stdout`&period;
| xref:BloombergLP/ball/AsyncFileObserver/setStdoutThreshold.adoc[`setStdoutThreshold`] 
| Set the minimum severity of records logged to `stdout`&period;
| xref:BloombergLP/ball/AsyncFileObserver/shutdownPublicationThread.adoc[`shutdownPublicationThread`] 
| Stop the publication thread without draining the record queue&period;
| xref:BloombergLP/ball/AsyncFileObserver/startPublicationThread.adoc[`startPublicationThread`] 
| Start a thread that asynchronously publishes queued log records&period;
| xref:BloombergLP/ball/AsyncFileObserver/stdoutThreshold.adoc[`stdoutThreshold`] 
| Return the minimum severity of records logged to `stdout`&period;
| xref:BloombergLP/ball/AsyncFileObserver/stopPublicationThread.adoc[`stopPublicationThread`] 
| Drain the record queue, then stop the publication thread&period;
| xref:BloombergLP/ball/AsyncFileObserver/suppressUniqueFileNameOnRotation.adoc[`suppressUniqueFileNameOnRotation`] 
| Suppress or enable unique filenames when rotating the log file&period;
| xref:BloombergLP/ball/AsyncFileObserver/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;AsyncFileObserver, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/AsyncFileObserver/publish-0d.adoc[`publish`] 
| Import the base&hyphen;class `publish` overloads&period;
|===



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