Boost C++ Libraries

PrevUpHomeNext

Class template basic_record_ostream

boost::log::basic_record_ostream — Logging record adapter with a streaming capability.

Synopsis

// In header: <boost/log/sources/record_ostream.hpp>

template<typename CharT, typename TraitsT = std::char_traits< CharT > > 
class basic_record_ostream : public std::basic_ostream< CharT, TraitsT > {
public:
  // types
  typedef std::basic_ostream< CharT, TraitsT > ostream_type;  // Stream type. 
  typedef basic_record< CharT >                record_type;   // Log record type. 
  typedef record_type::char_type               char_type;     // Character type. 
  typedef record_type::string_type             string_type;   // String type to be used as a message text holder. 

  // construct/copy/destruct
  basic_record_ostream();
  explicit basic_record_ostream(record_handle const &);
  basic_record_ostream(record_type const &);
  basic_record_ostream(basic_record_ostream const &);
  basic_record_ostream& operator=(basic_record_ostream const &);
  ~basic_record_ostream();

  // public member functions
  bool operator!() const;
  record_type const & record() const;
  void record(record_type);

  // private member functions
  void init_stream();
  void detach_from_record();
};

Description

This class allows to compose the logging record message by streaming operations. It aggregates the log record and provides the standard output stream interface.

basic_record_ostream public construct/copy/destruct

  1. basic_record_ostream();

    Default constructor. Creates an empty record that is equivalent to the invalid record handle. The stream capability is not available after construction.

    Postconditions:

    !*this == true

  2. explicit basic_record_ostream(record_handle const & rec);

    Conversion from a record handle. Adopts the record referenced by the handle.

    Parameters:
    rec

    The record handle being adopted

    Requires:

    The handle, if valid, have been issued by the logging core with the same character type as the record being constructed.

    Postconditions:

    this->handle() == rec

  3. basic_record_ostream(record_type const & rec);

    Conversion from a record object. Adopts the record referenced by the object.

    Parameters:
    rec

    The record handle being adopted

    Requires:

    The handle, if valid, have been issued by the logging core with the same character type as the record being constructed.

    Postconditions:

    this->handle() == rec

  4. basic_record_ostream(basic_record_ostream const &);
  5. basic_record_ostream& operator=(basic_record_ostream const &);
  6. ~basic_record_ostream();

    Destructor. Destroys the record, releases any sinks and attribute values that were involved in processing this record.

basic_record_ostream public member functions

  1. bool operator!() const;

    Conversion to an unspecified boolean type

    Inverted conversion to an unspecified boolean type

    Returns:

    true, if stream is valid and ready for formatting, false, if the stream is not valid. The latter also applies to the case when the stream is not attached to a log record.

    Returns:

    false, if stream is valid and ready for formatting, true, if the stream is not valid. The latter also applies to the case when the stream is not attached to a log record.

  2. record_type const & record() const;

    Flushes internal buffers to complete all pending formatting operations and returns the aggregated log record

    Returns:

    The aggregated record object

  3. void record(record_type rec);

    If the stream is attached to a log record, flushes internal buffers to complete all pending formatting operations. Then reattaches the stream to another log record.

    Parameters:
    rec

    New log record to attach to

basic_record_ostream private member functions

  1. void init_stream();
    The function initializes the stream and the stream buffer.
  2. void detach_from_record();
    The function resets the stream into a detached (default initialized) state.

PrevUpHomeNext