[#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. == Synopsis Declared in `<ball_observer.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Observer; ---- == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/Observer/2destructor.adoc[`~Observer`] [.small]#[destructor]# [.small]#[virtual]# | Destroy this observer. | 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. Note that this operation should be called if resources underlying the previously provided shared pointers must be released. |=== == Derived Classes [cols="1,4"] |=== | Name| Description | xref:BloombergLP/ball/AsyncFileObserver.adoc[`AsyncFileObserver`] | 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. | xref:BloombergLP/ball/BroadcastObserver.adoc[`BroadcastObserver`] | This class provides a broadcasting implementation of the `Observer` protocol. Other concrete observers may be registered and named with this broadcast observer (`registerObserver` method), retrieved (`findObserver` method), and unregistered (`deregisterObserver` method). The `publish` method of this class forwards the log records that it receives to the `publish` method of each registered observer. | xref:BloombergLP/ball/CstdioObserver.adoc[`CstdioObserver`] | This class provides a concrete implementation of the `Observer` protocol. The `publish` method of this class outputs the log records that it receives to a `FILE *` supplied at construction and then flushes the stream. | xref:BloombergLP/ball/FileObserver.adoc[`FileObserver`] | This class implements the `Observer` protocol. The `publish` method of this class outputs the log records that it receives 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. | xref:BloombergLP/ball/FileObserver2.adoc[`FileObserver2`] | This class implements the `Observer` protocol. The `publish` method of this class outputs the log records that it receives 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. | 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. The callback must be convertible to: ` bsl::function<bool(const Record&, const Context&)> ` 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. If the callback returns `false`, then the `Record` and `Context` are ignored (i.e., they are filtered out by this observer). | xref:BloombergLP/ball/MultiplexObserver.adoc[`MultiplexObserver`] | This class provides a multiplexing implementation of the `Observer` protocol. Other concrete observers may be registered with a multiplexing observer (`registerObserver` method) and later unregistered (`deregisterObserver` method). The `publish` method of this class forwards the log records that it receives to the `publish` method of each registered observer. | 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: `publish(const Record&, const Context&)`. | xref:BloombergLP/ball/StreamObserver.adoc[`StreamObserver`] | This class provides a concrete implementation of the `Observer` protocol. The `publish` method of this class outputs the log records that it receives to an instance of `bsl::ostream` supplied at construction. | xref:BloombergLP/ball/TestObserver.adoc[`TestObserver`] | This class provides an instrumented implementation of the `Observer` protocol suitable for testing systems that use `Observer`. 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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#