Boost logo

Boost Users :

Subject: Re: [Boost-users] Log: Filter expression in file stream init
From: Florian Lindner (mailinglists_at_[hidden])
Date: 2015-07-20 04:34:48


Another add:

BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity",
boost::log::trivial::severity_level)

Seems to have no effect at all... ???

Florian

Florian Lindner wrote:

> Florian Lindner wrote:
>
>> Hello,
>>
>> I have this piece of code: http://pastebin.com/iMyyaB6a
>>
>> It adds a file and a console log and reads in a file config:
>>
>> [Core]
>> # Filter="%Severity% > 1"
>>
>> [Sinks.MyConsoleSink1]
>> Destination=Console
>>
>> and prints some messages:
>>
>> using namespace boost::log::trivial;
>> boost::log::sources::severity_logger<severity_level> lg;
>> BOOST_LOG_SEV(lg, trace) << "A trace severity message";
>> BOOST_LOG_SEV(lg, debug) << "A debug severity message";
>> BOOST_LOG_SEV(lg, info) << "An informational severity message";
>> BOOST_LOG_SEV(lg, warning) << "A warning severity message";
>> BOOST_LOG_SEV(lg, error) << "An error severity message";
>> BOOST_LOG_SEV(lg, fatal) << "A fatal severity message";
>>
>> It does exactly what I want, prints each message twice to the console.
>> But when I uncomment the Filter expression it prints nothing.
>>
>> Why not? Severity > 1 means everything info and above, doesn't it?
>
> Ok, it seems in order to use Severity you got to register it before adding
> the sinks:
>
>
boost::log::register_simple_formatter_factory<boost::log::trivial::severity_level,
> char>("Severity");
>
boost::log::register_simple_filter_factory<boost::log::trivial::severity_level,
> char>("Severity");
>
> I thought that using the severity_logger is doing that for me. There is a
> bug report related to this https://svn.boost.org/trac/boost/ticket/8840,
> but it was closed for 1.54 and I am on 1.58.
>
> Curious,
> Florian


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