Boost logo

Boost :

Subject: [boost] Boost.logging bugs
From: Dmitriy Lyfar (dlyfar_at_[hidden])
Date: 2009-06-06 08:57:53


Hello,

We are using boost.logging library in our project. We prefered that library
because of header-only structure and
it looks great. But recently I have found some two bugs.
First of them its crash while output in syslog. I found that

    template<class msg_type> void operator()(const msg_type & msg) const {
        syslog( LOG_INFO, msg.c_str() );
    }

looks incorrect, because second argument is format string, so next line lead
boost.logging to crash:

amazon.co.uk%2fgp%2f%26nbsp%3b%2fref%3dpe_15031_15751501_pe_47%2f%26nbsp%3b

(I need output some html parts in syslog like debug info). So I replaced
code above with:

    template<class msg_type> void operator()(const msg_type & msg) const {
        syslog( LOG_INFO, "%s", msg.c_str() );
    }

Which works correct, but it seems not general solution. What do you think?
And the second one is compiling under gcc 3.4.6 issue:

../3rdparty/boost/boost_1_37_0/boost/logging/format/destination/syslog.hpp:
In member function `void
boost::logging::destination::syslog_no_levels_t<convert_dest>::operator()(const
msg_type&) const [with msg_type = std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, convert_dest =
boost::logging::destination::do_convert_destination]':

../3rdparty/boost/boost_1_37_0/boost/logging/detail/manipulator.hpp:571:
instantiated from `void
boost::logging::manipulator::detail::generic_holder<generic_type,
manipulator_base>::operator()(typename manipulator_base::param) const [with
generic_type =
boost::logging::destination::syslog_no_levels_t<boost::logging::destination::do_convert_destination>,
manipulator_base =
boost::logging::destination::base<boost::logging::default_,
boost::logging::default_>]'

LMLog.cpp:219: instantiated from here
../3rdparty/boost/boost_1_37_0/boost/logging/format/destination/syslog.hpp:41:
error: expected primary-expression

That can be fixed by pointing template keyword before operator() calling:
../3rdparty/boost/boost_1_37_0/boost/logging/detail/manipulator.hpp:571

Use
        virtual void operator()(param val) const {
            m_val.template operator()(val);
        }

Instead

        virtual void operator()(param val) const {
            m_val.operator()(val);
        }

Thank you for such library, I'm waiting for your comments.

Regards, Dmitriy Lyfar.


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