|
BDE 4.14.0 Production release
|
#include <ball_streamobserver.h>
Public Types | |
| typedef bsl::function< void(bsl::ostream &, const Record &)> | RecordFormatFunctor |
| typedef bsl::allocator< char > | allocator_type |
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (StreamObserver, bslma::UsesBslmaAllocator) | |
| StreamObserver (bsl::ostream *stream, const allocator_type &allocator=allocator_type()) | |
| ~StreamObserver () BSLS_KEYWORD_OVERRIDE | |
| Destroy this stream observer. | |
| void | publish (const bsl::shared_ptr< const Record > &record, const Context &context) BSLS_KEYWORD_OVERRIDE |
| void | releaseRecords () BSLS_KEYWORD_OVERRIDE |
| void | setRecordFormatFunctor (const RecordFormatFunctor &formatter) |
| virtual void | publish (const Record &record, const Context &context) |
| virtual void | publish (const bsl::shared_ptr< const Record > &record, const Context &context) |
Public Member Functions inherited from ball::Observer | |
| virtual | ~Observer () |
| Destroy this observer. | |
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.
| typedef bsl::allocator<char> ball::StreamObserver::allocator_type |
| typedef bsl::function<void(bsl::ostream&, const Record&)> ball::StreamObserver::RecordFormatFunctor |
RecordFormatFunctor is an alias for the type of the functor used for formatting log records to a stream.
|
explicit |
Create a stream observer that transmits log records to the specified stream. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. Note that a default record format is in effect for stream logging (see setLogFileFunctor).
| ball::StreamObserver::~StreamObserver | ( | ) |
| ball::StreamObserver::BSLMF_NESTED_TRAIT_DECLARATION | ( | StreamObserver | , |
| bslma::UsesBslmaAllocator | |||
| ) |
|
virtual |
Process the specified log record having the specified publishing context. The exact definition of publish depends on the implementing class, though the intention is that the log record (whose publication has occurred according to context) be distributed in a human or machine readable form.
Reimplemented from ball::Observer.
|
virtual |
Process the specified log record having the specified publishing context. Print record and context to the bsl::ostream supplied at construction. The behavior is undefined if record or context is modified during the execution of this method.
Reimplemented from ball::Observer.
Process the specified log record having the specified publishing context.
publish overload instead. Reimplemented from ball::Observer.
|
inlinevirtual |
Discard any shared reference to a Record object that was supplied to the publish method, and is held by this observer. Note that this operation should be called if resources underlying the previously provided shared-pointers must be released.
Reimplemented from ball::Observer.
| void ball::StreamObserver::setRecordFormatFunctor | ( | const RecordFormatFunctor & | formatter | ) |
Set the formatting functor used when writing records to the log file of this file observer to the specified formatter functor. Note that a default format ("\n%d %p %t %s %f %l %c %m %u\n") is in effect until this method is called (see ball_recordstringformatter ). 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.