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


I guess I can answer my own question now: It's probably not a good idea,
because of this function in the base class

    FinalT& operator= (FinalT that)
    {
        base_type::swap_unlocked(that);
        return static_cast< FinalT& >(*this);
    }

FinalT would in this case not point to the most-derived type, making this a
very strange operator=.

My question now is: How do I derive my own logger that has its own data
member(s) without having to duplicate ctors, etc. So far I've come up with
this ...

class Logger : public ::boost::log::sources::basic_composite_logger<
    char, Logger, ::boost::log::sources::multi_thread_model<
::boost::log::aux::light_rw_mutex >,
    typename ::boost::log::sources::features<
        ::boost::log::sources::severity< Severity >,
        ::boost::log::sources::channel< std::string > >::type >
{
    public:
        BOOST_LOG_FORWARD_LOGGER_CONSTRUCTORS(Logger)

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

    private:
        volatile Severity minimumSeverity;
};

... but this of course leaves minimumSeverity uninitialized. I tried to
implement default & copy ctor myself & use
BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_FORWARD, but that left me with strange
errors.

Thanks,

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