Boost logo

Boost Users :

Subject: [Boost-users] Composer issue with boost::log::sinks::event_log on VS2010
From: Konrad Rybacki (konrad.rybacki_at_[hidden])
Date: 2014-03-11 10:23:23


Hello,

I use basic_event_log_backend according to
documentation<http://www.boost.org/doc/libs/1_55_0/libs/log/doc/html/log/detailed/sink_backends.html#log.detailed.sink_backends.event_log.advanced_event_log_backend>-
I add formatters to events with
event_composer:

    sinks::event_log::event_composer composer(
        sinks::event_log::direct_event_id_mapping<int>("EventId")
    );

    composer[MSG1] % expr::attr<WORD>("Tag1");
    composer[MSG2] % expr::attr<DWORD>("Tag2");
    composer[MSG3] % expr::attr<std::string>("Tag3");

    backend->set_event_composer(composer);

Unfortunately event log entries in event viewer are incomplete - i.e.
there are still "%n"
placeholders instead of their values. From what I have found while
inspecting the code
with debugger it seems that event_map_reference& operator% (FormatterT
const& fmt)is never hit - so m_EventMap in composer is empty. I added
a method that works the same way
as mentioned operator:

            template< typename FormatterT >
            event_map_reference& add_formatter(FormatterT const &fmt)
            {
                m_Composer = m_Owner.add_formatter(m_ID, m_Composer,
formatter_type(fmt));
                return *this;
            }

 and call it explicitly, so the code looks like that:

    composer[MSG1].add_formatter(expr::attr<WORD>("Tag1"));
    composer[MSG2].add_formatter(expr::attr<DWORD>("Tag2"));
    composer[MSG3].add_formatter(expr::attr<std::string>("Tag3"));

Now m_EventMap has three items - and I get empty strings instead of
"%n" in event viewer.
I pass the tag values with boost macro, i.e.:

    BOOST_LOG_SCOPED_THREAD_TAG("Tag3", std::string("value"));

I am using Visual Studio 2010 compiler. Any ideas?

Regards,

Konrad.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net