This class provides a protocol for receiving and processing log record output.

Synopsis

Declared in <ball_observer.h>

class Observer;

Member Functions

Name

Description

~Observer [destructor] [virtual]

Destroy this observer.

publish

publish overloads

releaseRecords [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

Name

Description

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.

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.

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.

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.

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.

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).

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.

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&).

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.

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.

Created with MrDocs