Re: [Boost-bugs] [Boost C++ Libraries] #12887: I had a problem with boost.log when set the filter with & operator

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12887: I had a problem with boost.log when set the filter with & operator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-03-08 09:16:48


#12887: I had a problem with boost.log when set the filter with & operator
-------------------------------+---------------------
  Reporter: 136002018@… | Owner: andysem
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: log
   Version: Boost 1.62.0 | Severity: Problem
Resolution: wontfix | Keywords:
-------------------------------+---------------------
Changes (by andysem):

 * status: new => closed
 * resolution: => wontfix

Comment:

 The problem is that the operator is applied to an instance of
 `boost::log::value_ref`, which is basically an optional reference to the
 actual attribute value. `operator&` cannot be applied to it because the
 reference can be empty (e.g. if the log record does not contain the
 attribute), and in this case the operator cannot return any meaningful
 result.

 Currently, your best solution is to write your own filter function that
 will first test if the attribute value is found and then apply
 `operator&`.

 {{{
 bool my_filter(boost::log::value_ref<uint64, tag::attr_appenders> const&
 appenders)
 {
     uint64 mask = 0x01ul << _id;
     if (appenders)
         return (appenders.get() & mask) != 0;
     else
         return false; // the default
 }

 sink->set_filter(boost::phoenix::bind(&my_filter,
 attr_appenders.or_none()));
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12887#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-03-08 09:20:36 UTC