boost::log::sinks::basic_formatting_sink_backend — A base class for a logging sink backend with message formatting support.
// In header: <boost/log/sinks/basic_sink_backend.hpp> template<typename CharT, typename TargetCharT = CharT, typename ThreadingModelTagT = frontend_synchronization_tag> class basic_formatting_sink_backend : public boost::log::sinks::basic_sink_backend< CharT, ThreadingModelTagT > { public: // types typedef base_type::char_type char_type; // Character type. typedef base_type::string_type string_type; // String type to be used as a message text holder. typedef base_type::values_view_type values_view_type; // Attribute values view type. typedef base_type::threading_model threading_model; // Threading model tag. typedef base_type::record_type record_type; // Log record type. typedef std::basic_ostream< char_type > stream_type; // Output stream type. typedef TargetCharT target_char_type; // Target character type. typedef std::basic_string< target_char_type > target_string_type; // Target string type. // construct/copy/destruct basic_formatting_sink_backend(); ~basic_formatting_sink_backend(); // private member functions BOOST_MPL_ASSERT((mpl::or_< is_model_supported< threading_model, single_thread_tag >, is_model_supported< threading_model, frontend_synchronization_tag > >)); // public member functions template<typename T> void set_formatter(T const &); void reset_formatter(); std::locale getloc() const; std::locale imbue(std::locale const &); void consume(record_type const &); // protected member functions void do_consume(record_type const &, target_string_type const &); };
The basic_formatting_sink_backend
class template implements logging record formatting. Formatting requires storing auxiliary data, such as formatter and formatting stream. This requires thread synchronization to be done in sink frontend.
The class also supports performing encoding conversion in case if the sink backend requires the formatted string in some fixed encoding (e.g. if underlying API supports only narrow or wide characters). In order to perform conversion one should specify the desired final character type in the TargetCharT
template parameter.
basic_formatting_sink_backend
private member functionsBOOST_MPL_ASSERT((mpl::or_< is_model_supported< threading_model, single_thread_tag >, is_model_supported< threading_model, frontend_synchronization_tag > >));
basic_formatting_sink_backend
public member functionstemplate<typename T> void set_formatter(T const & fmt);
The method sets formatter functional object
Parameters: |
|
void reset_formatter();
The method resets the formatter. If the formatter is not set, the result of formatting is equivalent to the log record message text.
std::locale getloc() const;
The method returns the current locale used for formatting
std::locale imbue(std::locale const & loc);
The method sets the locale used for formatting
void consume(record_type const & record);
The method formats the message and passes it to the to the sink implementation by calling do_consume
.
Note | |
---|---|
Do not override in derived classes. Use |
Parameters: |
|