...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. 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; ~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; 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<<(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/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.
basic_record_ostream & operator<<(typename base_type::ios_base_manip manip);
basic_record_ostream & operator<<(typename base_type::basic_ios_manip manip);
basic_record_ostream & operator<<(typename base_type::stream_manip manip);
basic_record_ostream & operator<<(char c);
basic_record_ostream & operator<<(const char * p);
basic_record_ostream & operator<<(wchar_t c);
basic_record_ostream & operator<<(const wchar_t * p);
basic_record_ostream & operator<<(char16_t c);
basic_record_ostream & operator<<(const char16_t * p);
basic_record_ostream & operator<<(char32_t c);
basic_record_ostream & operator<<(const char32_t * p);
basic_record_ostream & operator<<(bool value);
basic_record_ostream & operator<<(signed char value);
basic_record_ostream & operator<<(unsigned char value);
basic_record_ostream & operator<<(short value);
basic_record_ostream & operator<<(unsigned short value);
basic_record_ostream & operator<<(int value);
basic_record_ostream & operator<<(unsigned int value);
basic_record_ostream & operator<<(long value);
basic_record_ostream & operator<<(unsigned long value);
basic_record_ostream & operator<<(long long value);
basic_record_ostream & operator<<(unsigned long long value);
basic_record_ostream & operator<<(float value);
basic_record_ostream & operator<<(double value);
basic_record_ostream & operator<<(long double value);
basic_record_ostream & operator<<(std::basic_streambuf< char_type, traits_type > * buf);