Get gravity boost.log logger ..?

Suppose I have a simple boost.log severity_logger logger configured as follows:

  logging::core::get()->set_filter(logging::trivial::severity >= logging::trivial::debug); logging::add_common_attributes(); src::severity_logger< logging::trivial::severity_level > logger; 

How can I check the severity programmatically?
That is, something like logger.getSeverity() ..?

I looked through the docs and other questions here on StackOverflow, but just couldn't find what should be a simple API call ..?

+6
source share
1 answer

I would say that you cannot. The logging system consists of three layers (see Overview of Logging System Design ).

  • Your severity_logger is the source logger with the severity_level attribute at the data collection level.

  • The severity set using logging::core::get()->set_filter(...) is the function object defined for the logging kernel. All messages sent to the log will be filtered by this function object before being sent to receivers.

Thus, there really is no such thing as severity - it is severity_logger . Heaviness is simply transmitted to the core, and then to the shell.


EDIT: set_filter my comment, you can also declare a severityLevel variable and pass it to the set_filter function (using boost::ref() link buffer)

 // defined somewhere: logging::trivial::severity_level severityLevel = logging::trivial::info; // passed to set_filter() by reference logging::core::get()->set_filter( logging::trivial::severity >= boost::ref(severityLevel)); // try out the logging: BOOST_LOG_SEV(logger, warning) << "A warning severity message"; // not filtered out severityLevel = logging::trivial::error; BOOST_LOG_SEV(logger, warning) << "Another warning message"; // filtered out 
+5
source

All Articles