[#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. == Synopsis Declared in `<ball_asyncfileobserver.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class AsyncFileObserver : public xref:BloombergLP/ball/Observer.adoc[Observer] ---- == Description This class implements the `Observer` protocol. The `publish` method of this class outputs log records asynchronously 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/AsyncFileObserver/OnFileRotationCallback.adoc[`OnFileRotationCallback`] | Alias for a user‐supplied callback invoked after log file rotation. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/AsyncFileObserver/2constructor-0b.adoc[`AsyncFileObserver`] [.small]#[constructor]# | Constructors | xref:BloombergLP/ball/AsyncFileObserver/2destructor.adoc[`~AsyncFileObserver`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this observer after draining and stopping publication. | xref:BloombergLP/ball/AsyncFileObserver/disableFileLogging.adoc[`disableFileLogging`] | Disable file logging for this async file observer. | xref:BloombergLP/ball/AsyncFileObserver/disablePublishInLocalTime.adoc[`disablePublishInLocalTime`] | Disable publishing of record timestamps in local time. | xref:BloombergLP/ball/AsyncFileObserver/disableSizeRotation.adoc[`disableSizeRotation`] | Disable log file rotation based on log file size for this async file observer. This method has no effect if rotation‐on‐size is not enabled. | xref:BloombergLP/ball/AsyncFileObserver/disableStdoutLoggingPrefix.adoc[`disableStdoutLoggingPrefix`] | Disable the long output format when logging to `stdout`. | xref:BloombergLP/ball/AsyncFileObserver/disableTimeIntervalRotation.adoc[`disableTimeIntervalRotation`] | Disable log file rotation based on a periodic time interval for this async file observer. This method has no effect if rotation‐on‐time‐interval is not enabled. | xref:BloombergLP/ball/AsyncFileObserver/enableFileLogging.adoc[`enableFileLogging`] | Enable file logging using a name derived from `logFilenamePattern`. | xref:BloombergLP/ball/AsyncFileObserver/enablePublishInLocalTime.adoc[`enablePublishInLocalTime`] | Enable publishing of record timestamps in local time. | xref:BloombergLP/ball/AsyncFileObserver/enableStdoutLoggingPrefix.adoc[`enableStdoutLoggingPrefix`] | Enable the long output format when logging to `stdout`. | xref:BloombergLP/ball/AsyncFileObserver/forceRotation.adoc[`forceRotation`] | Force an immediate log file rotation by this observer. | xref:BloombergLP/ball/AsyncFileObserver/getFileLogFormat.adoc[`getFileLogFormat`] | Return the format specification used for log‐file records. | xref:BloombergLP/ball/AsyncFileObserver/getLogFormat.adoc[`getLogFormat`] | Load the log‐file and `stdout` format specifications. | xref:BloombergLP/ball/AsyncFileObserver/getStdoutLogFormat.adoc[`getStdoutLogFormat`] | Return the format specification used for `stdout` log records. | 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. | xref:BloombergLP/ball/AsyncFileObserver/isPublishInLocalTimeEnabled.adoc[`isPublishInLocalTimeEnabled`] | Return `true` if published timestamps are written in local time. | xref:BloombergLP/ball/AsyncFileObserver/isStdoutLoggingPrefixEnabled.adoc[`isStdoutLoggingPrefixEnabled`] | Return `true` if the long `stdout` output format is in use. | xref:BloombergLP/ball/AsyncFileObserver/isSuppressUniqueFileNameOnRotation.adoc[`isSuppressUniqueFileNameOnRotation`] | Return `true` if the log filename uniqueness check on rotation is suppressed, and false otherwise. | xref:BloombergLP/ball/AsyncFileObserver/isUserFieldsLoggingEnabled.adoc[`isUserFieldsLoggingEnabled`] [.small]#[deprecated]# | Return `true` if the logging of user‐defined fields is enabled for this async file observer, and `false` otherwise. | xref:BloombergLP/ball/AsyncFileObserver/localTimeOffset.adoc[`localTimeOffset`] | Return the local‐minus‐UTC offset captured at construction. | 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. | xref:BloombergLP/ball/AsyncFileObserver/releaseRecords.adoc[`releaseRecords`] [.small]#[virtual]# | Discard shared references to `Record` objects held by this observer. | xref:BloombergLP/ball/AsyncFileObserver/rotateOnSize.adoc[`rotateOnSize`] | Rotate the log file when its size exceeds the specified `size`. | 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. | 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‐on‐size is in effect, and 0 otherwise. | xref:BloombergLP/ball/AsyncFileObserver/setFileLogFormat.adoc[`setFileLogFormat`] | Set the format specification for log records written to the log file. | xref:BloombergLP/ball/AsyncFileObserver/setLogFormat.adoc[`setLogFormat`] | Same as `setLogFormats`. | xref:BloombergLP/ball/AsyncFileObserver/setLogFormats.adoc[`setLogFormats`] | Set the format specifications for log‐file and `stdout` records. | xref:BloombergLP/ball/AsyncFileObserver/setOnFileRotationCallback.adoc[`setOnFileRotationCallback`] | Set the callback invoked after each log file rotation attempt. | xref:BloombergLP/ball/AsyncFileObserver/setStdoutLogFormat.adoc[`setStdoutLogFormat`] | Set the format specification for log records written to `stdout`. | xref:BloombergLP/ball/AsyncFileObserver/setStdoutThreshold.adoc[`setStdoutThreshold`] | Set the minimum severity of records logged to `stdout`. | xref:BloombergLP/ball/AsyncFileObserver/shutdownPublicationThread.adoc[`shutdownPublicationThread`] | Stop the publication thread without draining the record queue. | xref:BloombergLP/ball/AsyncFileObserver/startPublicationThread.adoc[`startPublicationThread`] | Start a thread that asynchronously publishes queued log records. | xref:BloombergLP/ball/AsyncFileObserver/stdoutThreshold.adoc[`stdoutThreshold`] | Return the minimum severity of records logged to `stdout`. | xref:BloombergLP/ball/AsyncFileObserver/stopPublicationThread.adoc[`stopPublicationThread`] | Drain the record queue, then stop the publication thread. | xref:BloombergLP/ball/AsyncFileObserver/suppressUniqueFileNameOnRotation.adoc[`suppressUniqueFileNameOnRotation`] | Suppress or enable unique filenames when rotating the log file. | xref:BloombergLP/ball/AsyncFileObserver/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<AsyncFileObserver, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== == Using Declarations [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/AsyncFileObserver/publish-0d.adoc[`publish`] | Import the base‐class `publish` overloads. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#