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

This class provides a protocol for receiving and processing log record output&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Observer;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/Observer/2destructor.adoc[`&#126;Observer`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this observer&period;
| xref:BloombergLP/ball/Observer/publish-0b.adoc[`publish`] 
| `publish` overloads
| xref:BloombergLP/ball/Observer/releaseRecords.adoc[`releaseRecords`]  [.small]#[virtual]#
| Discard any shared references to `Record` objects that were supplied to the `publish` method, and are held by this observer&period; Note that this operation should be called if resources underlying the previously provided shared pointers must be released&period;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/AsyncFileObserver.adoc[`AsyncFileObserver`] 
| 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;
| xref:BloombergLP/ball/BroadcastObserver.adoc[`BroadcastObserver`] 
| This class provides a broadcasting implementation of the `Observer` protocol&period; Other concrete observers may be registered and named with this broadcast observer (`registerObserver` method), retrieved (`findObserver` method), and unregistered (`deregisterObserver` method)&period; The `publish` method of this class forwards the log records that it receives to the `publish` method of each registered observer&period;
| xref:BloombergLP/ball/CstdioObserver.adoc[`CstdioObserver`] 
| 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 a `FILE &ast;` supplied at construction and then flushes the stream&period;
| xref:BloombergLP/ball/FileObserver.adoc[`FileObserver`] 
| 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;
| xref:BloombergLP/ball/FileObserver2.adoc[`FileObserver2`] 
| This class implements the `Observer` protocol&period; The `publish` method of this class outputs the log records that it receives 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;
| xref:BloombergLP/ball/FilteringObserver.adoc[`FilteringObserver`] 
| This class provides a concrete implementation of the `Observer` protocol that filters the `Record` and `Context` objects passed to its `publish` method based on a callback (function or functor) supplied at construction&period; The callback must be convertible to&colon; &grave; bsl&colon;&colon;function&lt;bool(const Record&amp;, const Context&amp;)&gt; &grave; If the callback returns `true` for the `Record` and `Context`, then they are forwarded to the `publish` method of an observer also supplied at construction&period; If the callback returns `false`, then the `Record` and `Context` are ignored (i&period;e&period;, they are filtered out by this observer)&period;
| xref:BloombergLP/ball/MultiplexObserver.adoc[`MultiplexObserver`] 
| This class provides a multiplexing implementation of the `Observer` protocol&period; Other concrete observers may be registered with a multiplexing observer (`registerObserver` method) and later unregistered (`deregisterObserver` method)&period; The `publish` method of this class forwards the log records that it receives to the `publish` method of each registered observer&period;
| xref:BloombergLP/ball/ObserverAdapter.adoc[`ObserverAdapter`] 
| This class aids in the implementation of the `Observer` protocol by allowing clients to implement that protocol by implementing a single method signature&colon; `publish(const Record&amp;, const Context&amp;)`&period;
| xref:BloombergLP/ball/StreamObserver.adoc[`StreamObserver`] 
| 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;
| xref:BloombergLP/ball/TestObserver.adoc[`TestObserver`] 
| This class provides an instrumented implementation of the `Observer` protocol suitable for testing systems that use `Observer`&period; Each instance receives a unique (per process) integer identifier at construction, and keeps count of the number of records that it has published, as well as the contents of the most recently published record and context&period;
|===


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