//! Composition operator void operator() (record_type const& rec, insertion_list& insertions) const { std::size_t size = m_Formatters.size(); insertions.resize(size); for (std::size_t i = 0; i < size; ++i) { log::aux::basic_ostringstreambuf< char_type > buf(insertions[i]); stream_type strm(&buf); m_Formatters[i](strm, rec); strm.flush(); } }
/*! * Formatting operator. Invokes all aggregated formatters, collects their formatting results * and composes them according to the format string passed on construction. * * \param strm A reference to the stream, where the final text of the logging record is composed * \param record A logging record */ void operator() (ostream_type& strm, record_type const& record) const { boost::log::aux::cleanup_guard< format_type > cleanup1(m_Format); boost::log::aux::cleanup_guard< streambuf_type > cleanup2(m_StreamBuf); { rdbuf_saver cleanup3(strm, &m_StreamBuf); for (typename formatters::const_iterator it = m_Formatters.begin(), end = m_Formatters.end(); it != end; ++it) { boost::log::aux::cleanup_guard< string_type > cleanup4(m_Buffer); (*it)(strm, record); strm.flush(); m_Format % m_Buffer; } } strm << m_Format.str(); }
//! Adds a new formatter to the list void add_formatter(formatter_type const& fmt) { m_Formatters.push_back(formatter_type(fmt)); }
fmt_format< char_type >& operator% (T const& fmt) { typedef typename wrap_if_not_formatter< char_type, T >::type result_type; m_Formatters.push_back(formatter_type(result_type(fmt))); return *this; }