Boost C++ Libraries

PrevUpHomeNext

Class template basic_formatting_sink_backend

boost::log::sinks::basic_formatting_sink_backend — A base class for a logging sink backend with message formatting support.

Synopsis

// 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 &);
};

Description

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 public construct/copy/destruct

  1. basic_formatting_sink_backend();

    Default constructor

    Postconditions:

    The sink backend base class is initialized. The formatter is not set.

  2. ~basic_formatting_sink_backend();

    Virtual destructor

basic_formatting_sink_backend private member functions

  1.  BOOST_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 functions

  1. template<typename T> void set_formatter(T const & fmt);

    The method sets formatter functional object

    Parameters:
    fmt

    Formatter object

  2. 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.

  3. std::locale getloc() const;

    The method returns the current locale used for formatting

  4. std::locale imbue(std::locale const & loc);

    The method sets the locale used for formatting

  5. 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] Note

    Do not override in derived classes. Use do_consume method to process the formatted message in a sink-specific manner.

    Parameters:
    record

    Log record to consume

basic_formatting_sink_backend protected member functions

  1. void do_consume(record_type const & record, 
                    target_string_type const & formatted_message);

    A backend-defined implementation of the formatted message processing

    Parameters:
    formatted_message

    Formatted log record

    record

    The original log record


PrevUpHomeNext