Boost logo

Boost :

From: John Torjo (john.groups_at_[hidden])
Date: 2008-02-04 19:14:09


> OK, so basically the library asks the user to initialize the log. Makes
> sense. Is there a way to quickly duplicate the configuration of one
> logger into another?
>
;) I've never thought of doing this.
If you were to use named loggers, duplicating its configuration would be
very easy:

#include <boost/logging/format/named_write.hpp>
typedef boost::logging::named_logger<>::type logger_type;
BOOST_DEFINE_LOG(g_l, logger_type)
BOOST_DEFINE_LOG(g_l_2, logger_type)

    // dumplicating the g_l log
    g_l_2()->writer().format( g_l()->writer().format() );
    g_l_2()->writer().destination( g_l()->writer().destination() );

If you have a regular logger (one that uses a writer which uses
formatters and destinations), there's no easy way to do this.
What you can do is this: add the same formatters/destinations to both
loggers:

formatter::time f("$mm:$ss");
g_l()->writer().add_formatter(f);
g_l_2()->writer().add_formatter(f);

Best,
John

-- 
http://John.Torjo.com -- C++ expert
http://blog.torjo.com
... call me only if you want things done right

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