Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost.Log unable to set logging filter (undeclared identifier 'severity')

I'm trying to get Boost.Log going in my project. The problem comes in the following line from the trivial example:

using namespace boost::log;
core::get()->set_filter
(
    trivial::severity >= trivial::info
);

In my code, this translates to the following:

boost::log::core::get()->set_filter(
  boost::log::trivial::severity >= boost::log::trivial::info
);

However, I get the following errors:

error C2039: 'severity' : is not a member of 'boost::log::v2s_mt_nt5::trivial'
error C2065: 'severity' : undeclared identifier

I'm kind of searching around the namespaces trying to find out how I'm supposed to do this, but I'm not really finding anything that works. It seems it's some crazy lambda function required for this. I'm alright with some alternative (defining a function that fills in the filtering level?), but I'm not sure how to accomplish this. Any ideas?

I'm using Boost.Log version 2.0-r862, and Boost 1.53.0.

SOLUTION: Ryan pointed out that I should check my includes, and sure enough I was only including trivial.hpp, but core.hpp and expressions.hpp are also required as includes. Including them solved the problem.

// need at least these 3 to get "trivial" to work
#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/trivial.hpp>
like image 442
aardvarkk Avatar asked May 01 '13 19:05

aardvarkk


1 Answers

Looking at trivial.hpp, it appears severity is part of the keywords namespace. Did you try boost::log::keywords::severity?

like image 119
Ryan Avatar answered Oct 03 '22 22:10

Ryan