Example:
typedef logger< gather::ostream_like::return_str<> , format_write<...> > logger_type; BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts ) BOOST_DEFINE_LOG(g_l, logger_type) #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( write_idx() ); g_l()->writer().add_formatter( write_time() ); g_l()->writer().add_formatter( append_newline() ); // write to cout and file g_l()->writer().add_destination( write_to_cout() ); g_l()->writer().add_destination( write_to_file("out.txt") ); // usage int i = 1; L_ << "testing " << i << i+1 << i+2;
In the above case:
write_idx()
is called, then write_time()
, then append_newline()
.write_to_cout()
, and then write_to_file()
.
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_type | What class you use to do allow thread-safe access to an instance of this clas (used internally). |