...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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 > { public: // 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. // 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; ~basic_record_ostream(); // 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; // 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/destructbasic_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.
Postconditions: |
|
explicit basic_record_ostream(record & rec);
Constructor from a record object. Attaches to the provided record.
Parameters: |
|
||
Requires: |
|
||
Postconditions: |
|
basic_record_ostream(basic_record_ostream const &) = delete;
basic_record_ostream & operator=(basic_record_ostream const &) = delete;
~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 functionsexplicit operator bool() const noexcept;
Conversion to an unspecified boolean type
Returns: |
|
bool operator!() const noexcept;
Inverted conversion to an unspecified boolean type
Returns: |
|
record & get_record();
Flushes internal buffers to complete all pending formatting operations and returns the aggregated log record
Returns: |
The aggregated record object |
record const & get_record() const;
Flushes internal buffers to complete all pending formatting operations and returns the aggregated log record
Returns: |
The aggregated record object |
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.
Parameters: |
|
void detach_from_record() noexcept;The function resets the stream into a detached (default initialized) state.