Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

ball::StreamObserver Class Reference

#include <ball_streamobserver.h>

Inheritance diagram for ball::StreamObserver:
ball::Observer

List of all members.

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())
virtual ~StreamObserver ()
virtual void publish (const bsl::shared_ptr< const Record > &record, const Context &context)
virtual void releaseRecords ()
void setRecordFormatFunctor (const RecordFormatFunctor &formatter)
virtual void publish (const Record &record, const Context &context)

Detailed Description

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.

See Component ball_streamobserver


Member Typedef Documentation

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.


Constructor & Destructor Documentation

ball::StreamObserver::StreamObserver ( bsl::ostream *  stream,
const allocator_type allocator = allocator_type() 
) [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).

virtual ball::StreamObserver::~StreamObserver (  )  [virtual]

Destroy this stream observer.


Member Function Documentation

ball::StreamObserver::BSLMF_NESTED_TRAIT_DECLARATION ( StreamObserver  ,
bslma::UsesBslmaAllocator   
)
virtual void ball::StreamObserver::publish ( const bsl::shared_ptr< const Record > &  record,
const Context context 
) [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.

virtual void ball::StreamObserver::releaseRecords (  )  [virtual]

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.

virtual void ball::Observer::publish ( const Record record,
const Context context 
) [virtual, inherited]

Process the specified log record having the specified publishing context.

DEPRECATED: Use the alternative publish overload instead.

Reimplemented in ball::FileObserver, ball::FileObserver2, ball::MultiplexObserver, ball::ObserverAdapter, and ball::TestObserver.


The documentation for this class was generated from the following file: