Boost logo

Boost :

Subject: [boost] [log] How to derive from a logger
From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2010-03-22 07:21:26


Hi Andrey

As discussed earlier, we're kind of desperate to add functionality to a
logger class provided by Boost.Log. Instead of duplicating
severity_channel_logger_mt, I'm wondering whether it's a good idea to derive
from it, as follows:

class Logger : public ::boost::log::sources::severity_channel_logger_mt<
Severity >
{
    public:
        typedef ::boost::log::sources::severity_channel_logger_mt< Severity
> logger_base;
        BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS(Tracer)

        void SetMinimumSeverity(Severity severity);
        Severity GetMinimumSeverity();

    private:
        Severity minimumSeverity;
};

Elsewhere we'd use this class as follows:

BOOST_LOG_DECLARE_GLOBAL_LOGGER_INIT(Whatever, Logger)
{
  // ...
}

It seems to work, but is this a good idea?

Thanks & Regards,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

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