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

This class provides a concrete implementation of the `Observer` protocol&period; The `publish` method of this class outputs the log records that it receives to an instance of `bsl&colon;&colon;ostream` supplied at construction&period;

== Synopsis

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

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

== 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/StreamObserver/RecordFormatFunctor.adoc[`RecordFormatFunctor`] 
| Alias for the record formatting functor type&period;
| xref:BloombergLP/ball/StreamObserver/RecordFormatter.adoc[`RecordFormatter`] 
| `LogRecordFunctor` is an alias for the type of the functor used for formatting log records to a stream&period;
| xref:BloombergLP/ball/StreamObserver/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias for the allocator used by this object&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/StreamObserver/2constructor.adoc[`StreamObserver`]         [.small]#[constructor]#
| Create a stream observer that transmits log records to the specified `stream`&period; Optionally specify an `allocator` (e&period;g&period;, the address of a `bslma&colon;&colon;Allocator` object) to supply memory&semi; otherwise, the default allocator is used&period; Note that a default record format is in effect for stream logging (see `logRecordDefault`)&period;
| xref:BloombergLP/ball/StreamObserver/2destructor.adoc[`&#126;StreamObserver`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this stream observer&period;
| xref:BloombergLP/ball/StreamObserver/disablePublishInLocalTime.adoc[`disablePublishInLocalTime`] 
| Disable publishing of the timestamp attribute of records in local time by this stream observer&semi; henceforth, timestamps will be in UTC time&period; This method has no effect if publishing in local time is not enabled&period;
| xref:BloombergLP/ball/StreamObserver/enablePublishInLocalTime.adoc[`enablePublishInLocalTime`] 
| Enable publishing of the timestamp attribute of records in local time by this stream observer&period; By default, timestamps are published in UTC time&period; Note that this method also affects timestamps for formatters that use them&period;
| xref:BloombergLP/ball/StreamObserver/getFormat.adoc[`getFormat`] 
| Return the format config of the last successful `setFormat` call&period;
| xref:BloombergLP/ball/StreamObserver/isPublishInLocalTimeEnabled.adoc[`isPublishInLocalTimeEnabled`] 
| Return `true` if this observer writes the timestamp attribute of records that it publishes in local time by default, and `false` otherwise (in which case timestamps are written by default in UTC time)&period;
| xref:BloombergLP/ball/StreamObserver/publish-03.adoc[`publish`] 
| `publish` overloads
| xref:BloombergLP/ball/StreamObserver/releaseRecords.adoc[`releaseRecords`]  [.small]#[virtual]#
| Discard any shared reference to a `Record` object that was supplied to the `publish` method, and is held by this observer&period; Note that this operation should be called if resources underlying the previously provided shared&hyphen;pointers must be released&period; This method intentionally does nothing as such resources are held, we publish all records immediately&period;
| xref:BloombergLP/ball/StreamObserver/setFormat.adoc[`setFormat`] 
| Set the formatting functor used when writing records to the stream of this stream observer to a log file functor created according to the specified, possibly URI&hyphen;like scheme tagged, `format`&period; Return zero if the setup with the specified arguments was successful and also save the `format` to be later retrievable using `getFormat`&period; Otherwise (if no matching scheme could be found or the configuration is invalid) return a non&hyphen;zero value and do not change the log record formatter used by this object&period; Note that a default format (&quot;n%d %p %t %s %f %l %c %m %un&quot;) is in effect until this method or `setRecordFormatFunctor` is called&period; Also, notice that the observer emits newline characters at the beginning and at the end of a log record by (the) default (format), so the user needs to add them explicitly to (text) format strings to preserve that behavior&period;
| xref:BloombergLP/ball/StreamObserver/setRecordFormatFunctor.adoc[`setRecordFormatFunctor`] 
| Set the formatting functor used when writing records to the stream of this stream observer to the specified `formatter` functor&period; Note that a default format (&quot;n%d %p %t %s %f %l %c %m %un&quot;) is in effect until this method or `setFormat` is called (see `ball&lowbar;recordstringformatter`)&period; Also note that the observer emits newline characters at the beginning and at the end of a log record by default, so the user needs to add them explicitly to the format string to preserve this behavior&period; Note that this method is not able to communicate the timezone default settings to the `formatter`, prefer `setFormat`&period;
|===


== Using Declarations

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



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