Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class template basic_record_ostream

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


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

template<typename CharT> 
class basic_record_ostream : public basic_formatting_ostream< CharT > {
  // types
  typedef CharT                           char_type;    // Character type. 
  typedef std::basic_string< char_type >  string_type;  // String type to be used as a message text holder. 
  typedef std::basic_ostream< char_type > stream_type;  // Stream type. 
  typedef base_type::traits_type          traits_type;  // Character traits. 

  // construct/copy/destruct
  basic_record_ostream() noexcept;
  explicit basic_record_ostream(record &);
  basic_record_ostream(basic_record_ostream const &) = delete;
  basic_record_ostream & operator=(basic_record_ostream const &) = delete;

  // public member functions
  explicit operator bool() const noexcept;
  bool operator!() const noexcept;
  record & get_record();
  record const & get_record() const;
  void attach_record(record &);
  void detach_from_record() noexcept;
  basic_record_ostream & operator<<(typename base_type::ios_base_manip);
  basic_record_ostream & operator<<(typename base_type::basic_ios_manip);
  basic_record_ostream & operator<<(typename base_type::stream_manip);
  basic_record_ostream & operator<<(char);
  basic_record_ostream & operator<<(const char *);
  basic_record_ostream & operator<<(wchar_t);
  basic_record_ostream & operator<<(const wchar_t *);
  basic_record_ostream & operator<<(char16_t);
  basic_record_ostream & operator<<(const char16_t *);
  basic_record_ostream & operator<<(char32_t);
  basic_record_ostream & operator<<(const char32_t *);
  basic_record_ostream & operator<<(bool);
  basic_record_ostream & operator<<(signed char);
  basic_record_ostream & operator<<(unsigned char);
  basic_record_ostream & operator<<(short);
  basic_record_ostream & operator<<(unsigned short);
  basic_record_ostream & operator<<(int);
  basic_record_ostream & operator<<(unsigned int);
  basic_record_ostream & operator<<(long);
  basic_record_ostream & operator<<(unsigned long);
  basic_record_ostream & operator<<(long long);
  basic_record_ostream & operator<<(unsigned long long);
  basic_record_ostream & operator<<(float);
  basic_record_ostream & operator<<(double);
  basic_record_ostream & operator<<(long double);
  basic_record_ostream & operator<<(const void *);
  basic_record_ostream & 
  operator<<(std::basic_streambuf< char_type, traits_type > *);

  // private member functions
  void init_stream();


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() noexcept;

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


    !*this == true

  2. explicit basic_record_ostream(record & rec);

    Constructor from a record object. Attaches to the provided record.



    The record handle being attached to


    !!rec == true


    &this->get_record() == &rec

  3. basic_record_ostream(basic_record_ostream const &) = delete;
  4. basic_record_ostream & operator=(basic_record_ostream const &) = delete;
  5. ~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. explicit operator bool() const noexcept;

    Conversion to an unspecified boolean type


    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.

  2. bool operator!() const noexcept;

    Inverted conversion to an unspecified boolean type


    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.

  3. record & get_record();

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


    The aggregated record object

  4. record const & get_record() const;

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


    The aggregated record object

  5. void attach_record(record & 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.



    New log record to attach to

  6. void detach_from_record() noexcept;
    The function resets the stream into a detached (default initialized) state.
  7. basic_record_ostream & operator<<(typename base_type::ios_base_manip manip);
  8. basic_record_ostream & operator<<(typename base_type::basic_ios_manip manip);
  9. basic_record_ostream & operator<<(typename base_type::stream_manip manip);
  10. basic_record_ostream & operator<<(char c);
  11. basic_record_ostream & operator<<(const char * p);
  12. basic_record_ostream & operator<<(wchar_t c);
  13. basic_record_ostream & operator<<(const wchar_t * p);
  14. basic_record_ostream & operator<<(char16_t c);
  15. basic_record_ostream & operator<<(const char16_t * p);
  16. basic_record_ostream & operator<<(char32_t c);
  17. basic_record_ostream & operator<<(const char32_t * p);
  18. basic_record_ostream & operator<<(bool value);
  19. basic_record_ostream & operator<<(signed char value);
  20. basic_record_ostream & operator<<(unsigned char value);
  21. basic_record_ostream & operator<<(short value);
  22. basic_record_ostream & operator<<(unsigned short value);
  23. basic_record_ostream & operator<<(int value);
  24. basic_record_ostream & operator<<(unsigned int value);
  25. basic_record_ostream & operator<<(long value);
  26. basic_record_ostream & operator<<(unsigned long value);
  27. basic_record_ostream & operator<<(long long value);
  28. basic_record_ostream & operator<<(unsigned long long value);
  29. basic_record_ostream & operator<<(float value);
  30. basic_record_ostream & operator<<(double value);
  31. basic_record_ostream & operator<<(long double value);
  32. basic_record_ostream & operator<<(const void * value);
  33. basic_record_ostream & 
    operator<<(std::basic_streambuf< char_type, traits_type > * buf);

basic_record_ostream private member functions

  1. void init_stream();
    The function initializes the stream and the stream buffer.