boost::logging::logger< gather_msg, write_msg > Struct Template Reference

The logger class. Every log from your application is an instance of this (see workflow). More...

Inheritance diagram for boost::logging::logger< gather_msg, write_msg >:
Collaboration diagram for boost::logging::logger< gather_msg, write_msg >:

List of all members.

Public Member Functions

< self_type,
gather_type > 
read_msg () const

Detailed Description

template<class gather_msg, class write_msg>
struct boost::logging::logger< gather_msg, write_msg >

The logger class. Every log from your application is an instance of this (see workflow).

As described in workflow, processing the message is composed of 2 things:

The logger class has 2 template parameters:

gather_msg A new gather instance is created each time a message is written. The gather_msg class needs to be default-constructible. The gather_msg must have a function called .msg() which contains all information about the written message. It will be passed to the write_msg class. You can implement your own gather_msg class, or use any from the gather namespace.
write_msg This is the object that does the second step - the writing of the message. It can be a simple functor. Or, it can be a more complex object that contains logic of how the message is to be further formatted, and written to multiple destinations. You can implement your own write_msg class, or it can be any of the classes defined in writer namespace. Check out writer::format_write - which allows you to use several formatters to further format the message, and then write it to destinations.

You will seldom need to use the logger class directly. You can use other wrapper classes.

The logger forwards the gathering of the message to the gather_msg class. Once all message is gathered, it's passed on to the writer. This is usually done through a macro.

    typedef logger< ... > logger_type;
    BOOST_DECLARE_LOG_FILTER(g_log_filter, filter::no_ts ) 
    BOOST_DECLARE_LOG(g_l, logger_type) 

    #define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) 

    // usage
    L_ << "this is so cool " << i++;

To understand more on the workflow that involves logging:


cache_before_init.cpp, custom_fmt_dest.cpp, ded_loger_one_filter.cpp, fastest_no_ostr_like.cpp, fastest_use_ostr_like.cpp, mul_levels_mul_logers.cpp, mul_levels_one_logger.cpp, mul_loggers_one_filter.cpp, no_levels_with_route.cpp, one_loger_one_filter.cpp, ts_loger_one_filter.cpp, use_profiler.cpp, use_tss_ostringstream.cpp, using_tags.cpp, and your_scenario.cpp.

Member Function Documentation

template<class gather_msg, class write_msg>
gather_holder<self_type, gather_type> boost::logging::logger< gather_msg, write_msg >::read_msg (  )  const [inline]

reads all data about a log message (gathers all the data about it)

The documentation for this struct was generated from the following file:

Copyright John Torjo © 2007
Have a question/ suggestion/ comment? Send me feedback