Boost logo

Boost :

Subject: Re: [boost] Boost.log: set_channel name dynamically for a basic_composite_logger
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-10-15 15:17:18


On Sunday, October 14, 2012, syvyi <alexander.svk_at_[hidden]> wrote:
> Here is the whole code:

[snip]

> class my_logger_mt :
> public src::basic_composite_logger<
> char,
> my_logger_mt,
>
src::multi_thread_model<boost::log2_mt_nt5::aux::light_rw_mutex>,

Don't use anything from aux namespace, it's implementation detail. I
suggest using boost::shared_mutex instead.

> src::features<
> src::severity< severity_levels >,
> src::exception_handler,
> src::channel< std::string >
> >
> >
> {
> BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS(my_logger_mt)
> };
>
> BOOST_LOG_DECLARE_GLOBAL_LOGGER_INIT(my_logger, my_logger_mt)

Replace with BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(my_logger, my_logger_mt).

> {
> my_logger_mt lg( keywords::channel = "channel!" );
> // my_logger_mt lg;
> // Set up exception handler: all exceptions that occur while
> // logging through this logger, will be suppressed
> lg.set_exception_handler(logging::make_exception_suppressor());
>
> return lg;
> }

[snip]

> int _tmain(int argc, _TCHAR* argv[])
> {

[snip]

> boost::shared_ptr< logging::attribute > pCounter(new
attrs::counter<
> unsigned int >(1));
> logging::core::get()->add_global_attribute("LineID", pCounter);

Replace with:

logging::core::get()->add_global_attribute("LineID", attrs::counter<
unsigned int >(1));

Similarly modify the following attribute adding code.

> boost::shared_ptr< logging::attribute > pTimeStamp(new
> attrs::local_clock());
> logging::core::get()->add_global_attribute("Date_time", pTimeStamp);
> boost::shared_ptr< logging::attribute > pNamedScope(new
> attrs::named_scope());
> logging::core::get()->add_global_attribute("Scope", pNamedScope);

[snip]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk