Public Member Functions | |
| template<class formatter> | |
| void | add_formatter (formatter fmt) |
| Adds a formatter. | |
| template<class formatter> | |
| void | add_formatter (formatter fmt, const char_type *format_str) |
| Adds a formatter. Also, the second argument is the spacer string. | |
| template<class formatter> | |
| void | del_formatter (formatter fmt) |
| Deletes a formatter. | |
| template<class destination> | |
| void | add_destination (destination dest) |
| Adds a destination. | |
| template<class destination> | |
| void | del_destination (destination dest) |
| Deletes a destination. | |
| router_type & | router () |
| const router_type & | router () const |
| template<class msg_type> | |
| void | operator() (msg_type &msg) const |
Once the message has been gathered, it's time to write it. The current class defines the following concepts:
You can add several formatters and destinations. Note that each formatter class and each destination class is a manipulator. Make sure you know what a manipulator is before using formatters and destinations.
typedef logger< gather::ostream_like::return_cache_str<> , format_write< ... > > logger_type; BOOST_DECLARE_LOG(g_l, logger_type) BOOST_DECLARE_LOG_FILTER(g_log_filter, filter::no_ts ) #define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) // add formatters : [idx] [time] message [enter] g_l()->writer().add_formatter( formatter::idx() ); g_l()->writer().add_formatter( formatter::time("$hh:$mm.$ss ") ); g_l()->writer().add_formatter( formatter::append_newline() ); // write to cout and file g_l()->writer().add_destination( destination::cout() ); g_l()->writer().add_destination( destination::file("out.txt") ); // usage int i = 1; L_ << "testing " << i << i+1 << i+2;
In the above case, formatter::idx() is called, then formatter::time(), then formatter::append_newline(). Now, the destinations are called: destination::cout(), and then destination::file().
Most of the time this is ok, and this is what the default router does. However, there are other routers in the msg_route namespace. For instance, take a look at msg_route::with_route class.
operator() on the formatters , and operator() on the destinations. Otherwise, take a look at format_and_write namespace.An object of this type (apply_format_and_write) is created for each new logged message.
| format_base | The base class for all formatter classes from your application. See manipulator. | |
| destination_base | The base class for all destination classes from your application. See manipulator. | |
| lock_resource | How will we lock important resources - routing them (msg_route) | |
| apply_format_and_write | [optional] The class that knows how to call the formatters and destinations. See The apply_format_and_write object | |
| router_type | [optional] The class that knows when to call the formatters, and when to call the destinations. See The router object. |
| void boost::logging::writer::format_write< formatter_base, destination_base, lock_resource, apply_format_and_write, router_type, formatter_array, destination_array >::add_formatter | ( | formatter | fmt | ) | [inline] |
| void boost::logging::writer::format_write< formatter_base, destination_base, lock_resource, apply_format_and_write, router_type, formatter_array, destination_array >::add_formatter | ( | formatter | fmt, | |
| const char_type * | format_str | |||
| ) | [inline] |
| void boost::logging::writer::format_write< formatter_base, destination_base, lock_resource, apply_format_and_write, router_type, formatter_array, destination_array >::del_formatter | ( | formatter | fmt | ) | [inline] |
| router_type& boost::logging::writer::format_write< formatter_base, destination_base, lock_resource, apply_format_and_write, router_type, formatter_array, destination_array >::router | ( | ) | [inline] |
returns the object that actually routes the message
| const router_type& boost::logging::writer::format_write< formatter_base, destination_base, lock_resource, apply_format_and_write, router_type, formatter_array, destination_array >::router | ( | ) | const [inline] |
returns the object that actually routes the message
| void boost::logging::writer::format_write< formatter_base, destination_base, lock_resource, apply_format_and_write, router_type, formatter_array, destination_array >::operator() | ( | msg_type & | msg | ) | const [inline] |
does the actual write