Boost logo

Boost Users :

Subject: [Boost-users] [Log] Attribute formatting tricks ineffective -- my enums are printed as numbers.
From: Andres Jaan Tack (andres.jaan.tack_at_[hidden])
Date: 2013-12-10 20:16:13


I'm having some trouble with attribute formatting in boost::log that I
haven't managed to figure out on my own. The case seems basic: I want to
format my own severity enum as a string, for which I've produced the
following (failing) example. Tested on clang-3.3 and clang-3.4 with
boost-1.54 from macports, the minimal failing test produces the following
output:

    $ clang++ --std=c++11 -c -DBOOST_ALL_DYN_LINK
-I/opt/local/include/boost fail.cxx
    $ g++ -o fail -L/opt/local/lib -lboost_log-mt -lboost_log_setup-mt
-lboost_system-mt -lboost_thread-mt fail.o
    $ ./fail
    1: Booo!

I would have expected "INFO: Booo!" according to my code.

I've attached the complete fail.cxx here, in which I do all of:

 1) Employ BOOST_LOG_ATTRIBUTE_KEYWORD,
 2) Overload operator<< (std::ostream&, const my::severity&),
 3) Overload operator<< (logging::formatting_ostream&, const
logging::to_log_manip<...>&), and
 4) Invoke register_simple_formatter_factory

I can't find any guidance in the documentation or elsewhere on the internet
that has managed to solve this -- Am I missing something obvious, or have I
found a failing test case?

--
Andres




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